Custom Menu - items disabled

K

Kevin Ayton

Can one of the experts out there help me with this?

I have a Visio application that worked fine under Visio 2000. When I opened
the document I added a custom menu with a number of items.

I've now upgraded to Visio 2003, and while the menu gets created, the items
on the menu are greyed out and can't be actioned. What do I need to change?

Code sample below:

Private Sub Document_DocumentOpened(ByVal doc As IVDocument)

' Add menu with a number of items....

Dim UIObj As Visio.UIObject
Dim menuObj As Visio.Menu
Dim menuitemObj As Visio.MenuItem

Set UIObj = Visio.Application.BuiltInMenus

' Insert new menu after Tools
Set menuObj = UIObj.MenuSets.ItemAtID(visUIObjSetDrawing).Menus.AddAt(7)
menuObj.Caption = "My Menu"

' Add item - Asset Properties
Set menuitemObj = menuObj.MenuItems.Add
With menuitemObj
.Caption = "Asset Properties..."
'.CmdNum = 0
.Enabled = True
.ActionText = "Display properties of the selected assets"
.AddOnName = "frmProperties.Display"
End With

' <snip - repeat several times, for each item>

' Now display the modified menu for this document...
ThisDocument.SetCustomMenus UIObj

'Instantiate the linked database
Set adbAssetDB = New AssetDB

End Sub

I know the code is being executed, becaus if I comment it out, the menu is
not added.

Thanks in Advance

Kevin
 
J

junethesecond

What is "frmProperties.Display" ?
One of the alternatives might be,
AddOnName = "macroname"
Here, "macroname" is
Sub macroname()
Application.DoCmd 1312
End Sub
 
K

Kevin Ayton

junethesecond said:
What is "frmProperties.Display" ?
One of the alternatives might be,
AddOnName = "macroname"
Here, "macroname" is
Sub macroname()
Application.DoCmd 1312
End Sub

frmProperties is a form within the project, and Display is a public
subroutine that makes it visible.

Does that make any difference?

TIA

Kevin
 
J

junethesecond

I see, but I did never have put it in itself.
Though I am not sure why your code does not work
when it is in the form itself, your code works normally if it is in
ThisDocument.
For example,
.AddOnName = "ThisDocument.ShowForm"
in place of
.AddOnName = "frmProperties.Display"
and in ThisDocument,
Sub ShowForm()
frmProperties.Show
End Sub
 
J

junethesecond

Of course, next may work well,
.AddOnName = "ThisDocument.ShowForm"
in your code in ThisDocument, and
Sub ShowForm()
frmProperties.Display
End Sub
in ThisDocument, where Display is your subroutine in the form,
I suppose it may be in your form,
Sub Display()
Me.Show
End Sub
 
K

Kevin Ayton

junethesecond said:
I see, but I did never have put it in itself.
Though I am not sure why your code does not work
when it is in the form itself, your code works normally if it is in
ThisDocument.
For example,
.AddOnName = "ThisDocument.ShowForm"
in place of
.AddOnName = "frmProperties.Display"
and in ThisDocument,
Sub ShowForm()
frmProperties.Show
End Sub

Brilliant! I changed my code to have an 'action routine' in ThisDocument
invoked from the menu which in turn called the 'real' code, and it all works
perfectly. Something must have changed from Visio 2000 to VIsio 2002/3.

Thaks for your help - much appreciated.

Kevin
 

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