M
Mike
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 ErrorAutpen
'loads menubar item for date picker and sheet re-activation
Call addMenuBarItem
ExitAutpen:
On Error Resume Next
Exit Sub
ErrorAutpen:
Resume ExitAutpen
End Sub
If anyone has a suggestion or knows this to be a bug in Visio - Thanks!
-Mike
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 ErrorAutpen
'loads menubar item for date picker and sheet re-activation
Call addMenuBarItem
ExitAutpen:
On Error Resume Next
Exit Sub
ErrorAutpen:
Resume ExitAutpen
End Sub
If anyone has a suggestion or knows this to be a bug in Visio - Thanks!
-Mike