Bo said:
When installing a WORD VBA application I add a menu item to Words
menu bar and I would like to have an image on that menu item. I know
how to do it manually, but how can I do in code?
I've only done it in Excel, but I would imagine it's very similar in Word.
When adding the menu item, can you specify it's .FaceId property? Here's
some code I keep in the same workbook, to work out a good value for that...
' **************************************************
' The menu code in this workbook originated on
' John Walkenbach's website.
'
http://j-walk.com/ss/excel/tips/tip53.htm
'
http://j-walk.com/ss/excel/tips/tip40.htm
' **************************************************
Option Explicit
Public Sub ShowFaceIDs(Optional ByVal StartID As Long = 1)
Dim NewToolbar As CommandBar
Dim NewButton As CommandBarButton
Dim i As Integer, IDStart As Integer, IDStop As Integer
' Delete existing FaceIds toolbar if it exists
On Error Resume Next
Application.CommandBars("FaceIds").Delete
On Error GoTo 0
' Add an empty toolbar
Set NewToolbar = Application.CommandBars.Add _
(Name:="FaceIds", temporary:=True)
NewToolbar.Visible = True
' Show 250 FaceID's starting with the value passed.
If StartID <= 0 Then StartID = 1
For i = StartID To (StartID + 249)
Set NewButton = NewToolbar.Controls.Add _
(Type:=msoControlButton, ID:=2950)
NewButton.FaceId = i
NewButton.Caption = "FaceID = " & i
Next i
NewToolbar.Width = 600
End Sub