Home Products Tips VBA OfficeOne on Windows Links

SetCommandBarButtonColor()

The following routine sets the color of a CommandBarButton. It does this by creating a bitmap (bmp) file with that color picture in it and then loading it to the CommandBarButton's Picture property.

Sub SetCommandBarButtonColor(ByVal CBB As CommandBarButton, ByVal Color As Long)
    Dim Pres As Presentation
    Dim Sld As Slide
    Dim Shp As Shape

    Set Pres = Presentations.Add(False)
    Set Sld = Pres.Slides.Add(1, ppLayoutBlank)
    Set Shp = Sld.Shapes.AddShape(msoShapeRectangle, 1, 1, 16, 16)
    Shp.Line.Visible = False
    Shp.Fill.ForeColor.RGB = Color
    Shp.Copy
    CBB.PasteFace
    Pres.Close
End Sub

Click here for Windows side of this code.


Home | Products | Tips | VBA | Windows | Links

Contact OfficeOne on email at officeone@officeonemac.com. Copyright © 2001-2013 OfficeOne. All rights reserved.

page counter