Custom Images

Create a bitmap to represent your button image
The best graphic format to use for custom images is PNG (portable network graphics) as it supports an alpha channel and results in small file sizes

Click the Resources tab and click Add Existing File from the add resource drop-down
Navigate to the bmp file and add it to your project
In the solution explorer select the bmp and set the Build property to Embedded Resource.

Add the following code to the end of the Ribbon1.vb file after End Class
This action adds a new class to your project that converts bitmaps to a picture type (IPictureDisp) that the Ribbon understands

Public Class BitmapToIPicture Inherits System.Windows.Forms.AxHost 
   Public Sub New()
   End Sub

   Public Shared Function Convert(ByVal Image as System.Drawing.Image) as stdole.IPictureDisp
      Convert = GetIPictureDispFromPicture(Image)
   End Function

End Class

Add the following code to the Ribbon1.vb class after the GetCustomUI function

Public Function GetImage(ByVal control as Office.IRibbonControl) as stdole.IPictureDisp 
   Return BitmapToIPicture.Convert(My.Resources.NAME)
End Function

© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext