user1547968
user1547968

Reputation: 57

Add Custom Image to button in excel ribbon

I'm developing a microsoft excel addin and added a button, but I need to add custom image to it. How to achieve that

  <button id="customButton1" label="myLabel" size="large" image="????" />

Upvotes: 0

Views: 3768

Answers (1)

Furqan Safdar
Furqan Safdar

Reputation: 16718

Try using this code snippet in the code-behind:

customButton1.Image = new Bitmap("Image.jpg");

OR

customButton1.Image = Image.FromFile(@"C:\Image.jpg");

How to: Add Custom Icons to Toolbar and Menu Items

  1. Create a new class named ConvertImage. This class uses System.Forms.Axhost to convert an image file to an image type that can be applied to the menu item.

  2. Add a method to convert the icon file into an Image file by adding it to an ImageList. This code sends the Image file to the ConvertImage.Convert method you created and then returns the file to the caller.

Upvotes: 1

Related Questions