|
-
Apr 4th, 2005, 05:15 AM
#1
Thread Starter
Addicted Member
VBA Menus
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
-
Apr 4th, 2005, 07:57 AM
#2
Addicted Member
Re: VBA Menus
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
if you fail to plan, you plan to fail
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|