Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

How to add an image on a menu item

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bo Hansson - 23 Nov 2005 21:48 GMT
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?

/BosseH
Karl E. Peterson - 23 Nov 2005 22:38 GMT
> 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

--
Working without a .NET?
http://classicvb.org/
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.