none
In VSTO Add-in, custom image is not loading from a resource file to Office Ribbon RRS feed

  • Question

  • I am using VSTO 2010 and Word 2007 application level Add-In to follow this MSDN Walkthrough: Creating a Custom Tab by Using Ribbon XML. In this walkthrough, I am doing just one additional thing and that is to add an image to the first button as folllows. I've added the following following value to the image attribute of the first button tag as: image="MyRibbonAddIn.Properties.Resources.image001"

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
      <ribbon>
        <tabs>
          <tab idMso="TabAddIns">
            <group id="MyGroup" label="My Group">
                <button id="textButton" label="Insert Text"  image="MyRibbonAddIn.Properties.Resources.image001" showImage="true" screentip="Text" onAction="OnTextButton" supertip="Inserts text at the cursor location."/>
                <button id="tableButton" label="Insert Table"
                     screentip="Table" onAction="OnTableButton"
                     supertip="Inserts a table at the cursor location."/>
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>

    This image image001 is a tiny 9x20 png image. When I run the Add-In, I can see that there is a blank space - to the left of the title of the first button – that seems to be the place holder of the image but the image is not showing up there. I have added the image to the Resource file Properties/Resources.resx of the project.
    When I mouse hover the image attribute in the Ribbon XML (shown above), he definition of the image attriute read as:  “Specifies a custom image or icon. Specifies a string argument which is a path to a file or a resource. String length is limited to a 1024 characters”. That means that in image attribute, you can specify the path to the resource if the image is embedded as resource.

    Please help. Thanks..Nam


    • Edited by namwam Saturday, October 13, 2012 4:04 AM Added more content
    Thursday, October 11, 2012 9:47 PM

Answers