Hi. I'm not sure what you mean by extracting FaceID. FaceID is just a number, like 17 or 19. If you mean you need the image on the button, then there's a way. First of all, standard MS images for icons consist of a picture itself and so called mask - "The mask image determines which parts of the button image are transparent. Always set the mask after you have set the picture for a CommandBarButton object" (from MS Excel VBA Help)
Here's a procedure to send both: a picture and a mask of a button to .bmp files :
Code:
Sub GetButtonImageAndMask()
Dim picPicture As IPictureDisp
Dim picMask As IPictureDisp
'This will reference the first button of the first commandbar.
With Application.CommandBars.FindControl(msoControlButton)
'Get the button image and mask of this CommandBarButton object.
Set picPicture = .Picture
Set picMask = .Mask
End With
'Save the button image and mask in a folder.
stdole.SavePicture picPicture, "C:\...(your path)...\ImageName.bmp"
stdole.SavePicture picMask, "C:\...(your path)...\MaskName.bmp"
End Sub
If you need to reference specific buttons, use FindControl method of the CommandBars collection.
The second routine creates a new command bar with a button and sets button's face using a picture from a file.
Code:
Sub ChangeButtonImage()
Dim c As CommandBar
Dim cb As CommandBarButton
Dim picPicture As IPictureDisp
Dim picMask As IPictureDisp 'you can also change the mask
Set picPicture = stdole.StdFunctions.LoadPicture( _
"c:\...(your path)...\iconName.bmp")
'optional - only of you have a mask file
Set picMask = stdole.StdFunctions.LoadPicture( _
"c:\...(your path)...\maskName.bmp")
On Error Resume Next
Application.CommandBars("BarName").Delete
Set c = Application.CommandBars.Add("BarName", msoBarFloating, False, True)
c.Enabled = True
c.Visible = True
Set cb = c.Controls.Add(msoControlButton, 1)
cb.Style = msoButtonIcon
cb.Tag = "ButtonTest"
'Set the picture
cb.Picture = picPicture
'Set the mask
cb.Mask = picMask
cb.OnAction = "ThisWorkbook.Test"
Set cb = Nothing
Set c = Nothing
End Sub
Hope it helps.
Regards,
Maria
There's always an answer. Your task is to find it.