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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Menu Bar - Visio

Status
Not open for further replies.

mavest

Programmer
Feb 27, 2003
54
US
I am trying to add a menu item to Visio's menu bar. I want to create it as the document opens and then delete as the document closes.

I have successfully created the menu item with the below sub. However when I call this sub from Visio's document_documentOpen routine the menu item is created, but then mysteriously deleted before the document is fully open. In fact you can see the menu item popup and then disappear!

Here's the sub that creates the menu item:

Sub addMenuBarItem()
On Error GoTo Error_addMenu

With Application.CommandBars.ActiveMenuBar.Controls
With .Add(Type:=msoControlPopup, before:=.Item("Help").Index, temporary:=False)
.Caption = "SCOT Utilities"
With .Controls.Add
.Caption = "Re Load Date Picker"
.OnAction = "'" & ThisDocument.Name & "'!loadDatePicker"
End With
With .Controls.Add
.Caption = "Re Activate XLS Link"
.OnAction = "'" & ThisDocument.Name & "'!activateShts"
End With
End With
End With

Exit_addMenu:
On Error Resume Next
Exit Sub

Error_addMenu:
MsgBox "error adding menu item to visio - see VBA routine addMenu()"
GoTo Exit_addMenu

End Sub

And Here's the document_documentOpen routine:

Public Sub Document_DocumentOpened(ByVal voDoc As Visio.Document)
On Error GoTo ErrorAuto_Open

'loads menubar item for date picker and sheet re-activation
Call addMenuBarItem

ExitAuto_Open:
On Error Resume Next
Exit Sub
ErrorAuto_Open:
Resume ExitAuto_Open
End Sub

If anyone has a suggestion or knows this to be a bug in Visio - Thanks!


-Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top