Hey all is it possible in VBA to create menus such as File, Edit to be placed at the top of a program i'm creating if so could anyone help?
thanks
James Bowtell
Printable View
Hey all is it possible in VBA to create menus such as File, Edit to be placed at the top of a program i'm creating if so could anyone help?
thanks
James Bowtell
James,
here is an example of custom menu which i have in a module, and which run at start up.
VB Code:
Sub db_Open(Cancel As Integer) Dim mymenubar As CommandBar Dim newmenu As CommandBarControl Dim ctrl1 As CommandBarButton Dim ctrl2 As CommandBarButton Dim ctrl3 As CommandBarButton 'set up custom menu bar to allow office links and print. 'standard ones are disabled in start up options for security 'the menu bar is reset on close of the db Set mymenubar = CommandBars.ActiveMenuBar Set newmenu = mymenubar.Controls.Add(Type:=msoControlPopup, Temporary:=True) newmenu.Caption = "Publish" Set ctrl1 = newmenu.Controls.Add(Type:=msoControlButton, Id:=1) With ctrl1 .Caption = "Publish - Word" .TooltipText = "Publish in Microsoft Word" .Style = msoButtonCaption .OnAction = "Publish_Word" End With Set ctrl2 = newmenu.Controls.Add(Type:=msoControlButton, Id:=2) With ctrl2 .Caption = "Publish - Excel" .TooltipText = "Publish in Microsoft Excel" .Style = msoButtonCaption .Enabled = True .OnAction = "Publish_Excel" End With Set ctrl3 = newmenu.Controls.Add(Type:=msoControlButton, Id:=3) With ctrl3 .Caption = "Print" .TooltipText = "Print Report" .Style = msoButtonCaption .Enabled = True .OnAction = "Print_Report" End With End Sub Private Sub db_Close() Dim mymenubar As CommandBar Set mymenubar = CommandBars.ActiveMenuBar mymenubar.Reset End Sub
I have macros for each of the menu options. i couldnt get it to work with code (was a while ago i wrote this).
the macros, are basic 'output to', or print out
HTH