More Custom Menu Problems in Visio 2002 
Author Message
 More Custom Menu Problems in Visio 2002


Most likely the sample code you reference is not working is because
ShowArgs.exe is not on your add-ons search path (Tools | Options | File
Paths tab | Add-ons).  Visio tries to be smart and hides buttons whose
add-on is not available, and Visio 2002 made some changes in the name of
security so that it will only run a) macros in the current or any other open
document or b) EXEs and add-ons in the add-ons search path.  (Previous
versions of Visio would run any random EXE.)  I believe this requirement is
documented in DMVS, but I'll verify that it is.

Also note that the ActionText is what is displayed on the Undo, Redo, and
Repeat menus, and has nothing to do with a menu item's tooltip.  The
UIObject never has had a tooltip property.

If such is the case the code below should work for you.  I made exactly two
changes from the MSDN sample:  I added a macro named React to the
ThisDocument VBA module, and I modified the Demo menu's AddOnName property
to be ThisDocument.React (i.e., the name of the macro I added).

Although we did switch the underlying mechanism from our custom command bars
over to MSO command bars, we put a lot of effort into keeping the
UIObject-related stuff working correctly.  If you find something we missed,
we definitely want to know about it.  A tiny bit of sample code that
demonstrates the problem is always of great help.

Option Explicit

'This Microsoft Visual Basic for Applications (VBA) macro
'demonstrates adding a menu and menu item to the drawing
'window menu set. This macro uses the AddAt method to add a menu
'before the Visio Window menu.

Public Sub AddMenuItem_Example()

    Dim UIObj As Visio.UIObject
    Dim menuSetsObj As Visio.MenuSets
    Dim menuSetObj As Visio.MenuSet
    Dim menusObj As Visio.Menus
    Dim menuObj As Visio.Menu
    Dim menuItemsObj As Visio.MenuItems
    Dim menuItemObj As Visio.MenuItem

    'Get a UI object that represents Microsoft Visio built-in menus
    Set UIObj = Visio.Application.BuiltInMenus

    'Get the MenuSets collection
    Set menuSetsObj = UIObj.MenuSets

    'Get the drawing window menu set
    Set menuSetObj = menuSetsObj.ItemAtID(visUIObjSetDrawing)

    'Get the menus collection
    Set menusObj = menuSetObj.Menus

    'Add a Demo menu before the Window menu.
    Set menuObj = menusObj.AddAt(7)
    menuObj.Caption = "Demo"

    'Get the menuItems collection
    Set menuItemsObj = menuObj.MenuItems

    'Add a menu item to the new Demo menu
    Set menuItemObj = menuItemsObj.Add

    'Set the properties for the new menu item
    menuItemObj.Caption = "Run &ShowArgs"
    menuItemObj.AddOnName = "ThisDocument.React"
    menuItemObj.AddOnArgs = "/DVS=Fun"
    menuItemObj.ActionText = "Run ShowArgs"

    'Tell Visio to use the new UI when the document is active.
    ThisDocument.SetCustomMenus UIObj

End Sub
Public Sub React()
    MsgBox "Boo"
End Sub

Sat, 09 Apr 2005 23:33:59 GMT  
 More Custom Menu Problems in Visio 2002
Thanks, Mike...I discovered my problem.  It seems that if you add a menu
without any menu items in it, it comes up as a blank menu header.  If you
add menu items to it, it comes up as it should and the text is visible.  I
was trying to add a menu and only adding the header to see if I could get it
to work.  As soon as I started adding menu items to it, it started working.

Thanks for your help,


> There seems to be a number of incompatibilities in Visio
> 2002 in the custom menus area because Microsoft has
> switched to using the Office CommandBars object instead
> of the older Visio UIObject.

> Specifically, I can't set the ActionText on a new menu I
> created using the UIObject method.  The following code
> results in a new menu being created with no menu text:

>        NewmenuObj = menusetObj.Menus.AddAt(6)
>        NewmenuObj.ActionText = "Demo"
>        NewmenuObj.Caption = "Demo"

> There are a number of other incompatibility issues in
> this area.  The example that Microsoft provides of using
> the UIObject interface to create a menu at the following
> address doesn't work at all!!!

> url=/library/en-us/devref/DAR_Examples_(A-B)_528.asp

> The only solution to this seems to be to use the
> commandbars approach.  My question is...if I use the
> CommandBars approach, will it be backward compatible with
> Visio 2000?

> Can someone from Microsoft please address this question?
> Also, it would be a good idea to replace or fix the
> examples like the one cited above in the MSDN
> Knowledgebase that no longer work. (Or at least put a
> note about Visio 2002 compatibility issues with them)

> Thanks,

> Chuck

Mon, 11 Apr 2005 00:35:43 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Custom Menu in Visio 2002

2. Visio 2002 custom menu frustration

3. Disabled custom menu items with VISIO 2002

4. Custom Menus in Visio 2002

5. VBA created menu in Visio 2002 is inactive?!

6. Visio 2000 & Visio 2002 Differences

7. SendToBack in Visio 2000 & Visio 2002

8. Creating Custom Menu in OL 2002

9. Custom menus in Visio

10. COM objects and Visio 2002

11. Disable Visio 2002 while program is working

12. Opening Visio 2002 modally from a .NET Form


Powered by phpBB® Forum Software