Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a user form from a custom menu 1

Status
Not open for further replies.

JTBorton

Technical User
Jun 9, 2008
345
DE
I am trying, rather unsuccesfully, to create a custom menu that will call a user form. I am having quite a bit of difficulty with the .onaction property.

This code is placed in a AddMenus() sub in ThisWorkBook and is called when the work book opens:

With cbcCutomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "&Agenda Editor"
.OnAction = " ' " & ThisWorkbook.Name & " '!AgendaEditor"
.Enabled = False
End With
.
.
.
(I want it to call this sub, placed directly under the above sub)
Sub AgendaEditor()
frmAgenda.Show
End Sub

When executed it tells me that the macro cannot be found.
 
I'm not sure of the syntax you're using. What if you put the second Macro in a module (rather than the sheet itself)? Then:
.OnAction = "AgendaEditor"

_________________
Bob Rashkin
 
Excellent! That worked perfectly. I had a little trouble at first because I forgot to make the sub public in the module but now my custom menu is purring like a panther!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top