Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, California, USA
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Custom image on custom UI button via vba (Office 2007)

    Hello all.

    I'd like to display a custom image on a button I've added to Word's 2007 UI. The catch is that I want to do it using only xml and vba code.

    Here's the scenario: I've got a Word 2007 template (.dotm) containing some vba procedures. I manually edited the template's customUI.xml, to add a custom group with a few buttons to the Ribbon. I've linked the buttons to different vba procedures in the template. Everything works fine.

    I would like to add custom images to my buttons. I've seen how to do this using a VSTO project (adding the images as project resources, writing callbacks, etc.). But is there a way to do this without resorting to VSTO? That is, can I customize my button images using only the customUI.xml file and adding vba code to my template?

    Any solutions, suggestions or commiseration would be greatly appreciated!

  2. #2
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,594
    Thanks
    5
    Thanked 1,059 Times in 928 Posts

    Re: Custom image on custom UI button via vba (Office 2007)

    Joe

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, California, USA
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Custom image on custom UI button via vba (Office 2007)

    Unfortunately, no. That article explains how to do it with a VSTO project, which is what I'm trying to avoid.

  4. #4
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,594
    Thanks
    5
    Thanked 1,059 Times in 928 Posts

    Re: Custom image on custom UI button via vba (Office 2007)

    The XML section at the top of that article shows a custom image for the button named button1. The following paragraph is from the same article:

    Next, the image attribute for button1 is used to specify a custom image for the button. Likewise, the imageMso attribute for button2 is used to specify a built-in image for the button.

    Is this not what you meant?

    Joe
    Joe

  5. #5
    Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, California, USA
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Custom image on custom UI button via vba (Office 2007)

    (Edited by HansV to make URL clickable - see <!help=19>Help 19<!/help>)

    Not exactly. I had already added the "image" tag in customUI.xml. I then needed to associate the image with the Ribbon and the template, and that's what I didn't know how to do.

    I ran across the answer in Eric Faller's very helpful article "RibbonX API: Extend The 2007 Office System With Your Own Ribbon Tabs And Controls" at http://msdn2.microsoft.com/en-us/magazine/cc163469.aspx.

    Following Eric's instructions, I used the Office 2007 Custom UI Editor to add the image, then I looked at the file to see what the UI Editor had done.

    It added two subfolders to the template's CustomUI folder: an "images" folder, to which it added my .jpg; and a _rels folder, in which it created customUI.xml.rels, which included new xml defining the image's relationship to the UI.

    So I'm all set. I hope this helps other folks who may be updating old templates with toolbars for their conversion to Office 2007.

    Thanks for your suggestions.

    Regards,

    Bob

  6. The Following User Says Thank You to Bob_McCoy For This Useful Post:

    ajulyguy (2012-08-11)

  7. #6
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,594
    Thanks
    5
    Thanked 1,059 Times in 928 Posts

    Re: Custom image on custom UI button via vba (Office 2007)

    Good!!! Glad you found some help that helped. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Thanks for posting back the solution.

    Joe
    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •