Visio menu - OnAction routine

S

Sydney

Hi, im using visio 2002 and xp developer.

I copied some code from the help files to create a toolbar The menu
creates itself beautifully but I cant get the OnAction to work, the error
reads : Method OnAction of object 'commandbarpopup' failed.
Any ideas would be appreciated.

Sub AddMenuToMenuBar() ' (vsoApplication As Visio.Application)

' Abstract - This procedure gets the active MenuBar from
' Visio and adds a Menu at the end called "Custom".

Dim cbrCommandBars As Office.CommandBars
Dim cbrMenuBar As Office.CommandBar
Dim cbrMenuPopup As Office.CommandBarPopup
Dim vsoApplication As Visio.Application

' Get the CommandBars collection from Visio.
Set vsoApplication = Visio.Application
Set cbrCommandBars = vsoApplication.CommandBars

' Get the active menu bar from the CommandBars collection.
Set cbrMenuBar = cbrCommandBars.ActiveMenuBar

Set cbrMenuPopup = cbrMenuBar.Controls.Add(Type:=msoControlPopup,
Temporary:=True)
With cbrMenuPopup
.Caption = "Visio Footer"
.Controls.Add.Caption = "Insert Footer"
.OnAction = "VIFooter" ' sub with footer code in the same module
fails..so close but not quite!
.TooltipText = "Insert a footer into the document"
End With

End Sub
 
J

JuneTheSecond

I've added next code simply after your code in the standard module, but there
is no problem. So the problrem may be in your VIFooter or its location.

Sub VIFooter()
MsgBox "TEST"
End Sub
 
S

sydney

Thats so strange...I just tried what you did.
Added the message box sub right after the toolbar code and still get the
same error?

Is that all you changed?
Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top