10

I have a custom button in outlook and I have to add image icon for the same button.

Ribbon XML is:

<button id="GoToAppConfiguration" 
    label="Application Configuration" 
    getImage="GetCustomImage" 
    onAction="GoToAppConfigurationClicked" 
    size="normal" />

I want to write ribbon callback method but how do I write the same and how do I use an image stored in a Resource folder under the Addin project.

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
zytham
  • 613
  • 1
  • 12
  • 27

1 Answers1

11

You just need to return a Bitmap from GetCustomImage. Here is a c# example, assuming you have added the BMP to your Project Resources.

public Bitmap GetCustomImage(Office.IRibbonControl control)
{
    return Properties.Resources.btnAppConfiguration_Image; // resource Bitmap
}
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
  • 1
    Doesn't the resource manager already give a copy of the image? It works fine if you specify Image instead of Bitmap – Drakarah Nov 20 '13 at 11:21
  • @drake7707 - good catch! I edited the answer for simplicity and removed the unnecessary `Bitmap` instance creation. It appears you can return either `Image` or `Bitmap` for the `getImage` signature - [`IPictureDisp GetImage(IRibbonControl control)`](http://msdn.microsoft.com/en-us/library/aa722523%28v=office.12%29.aspx). Outlook must handle the translation from `Image` to `IPictureDisp` internally. [`PictureDispConverter` is not required for Ribbon XML customizations](http://stackoverflow.com/a/16148015/175679). – SliverNinja - MSFT Nov 20 '13 at 15:22
  • @SliverNinja Do you have a link which shows all of the callback definitions for Ribbon XML? – The Muffin Man Nov 16 '14 at 23:39
  • 1
    I found it.. Scroll down towards the bottom to table 4. http://msdn.microsoft.com/en-us/library/aa722523.aspx – The Muffin Man Nov 17 '14 at 00:12
  • In order to make it, I had to add the method into the Ribbon class – Marco Alves Dec 23 '15 at 01:03