CustomMenusFile Property [Visio 2003 SDK Documentation]

Gets or sets the name of the file that defines custom menus and accelerators for an Application object or a Document object.

strRet = object**.CustomMenusFile**

object**.CustomMenusFile** = fileStr

strRet     String. The name of the file that defines the current custom menus for the object.

object     Required. An expression that returns the Application, InvisibleApp, or Document object.

fileStr     Required String. The name of the file that defines new custom menus for the object.

Version added

4.0

Remarks

If the object is not using custom menus, the CustomMenusFile property returns Nothing.

Example

This Microsoft Visual Basic for Applications (VBA) macro shows how to get the currently active UI for your document without replacing the application-level custom UI. It also saves any existing custom menus to a file and specifies that the current document use those menus. You must write additional code to add your custom UI items.

Note  This macro uses the VBA keyword Kill to delete a file on disk. Use this keyword carefully, because you cannot undo a Kill command once it has been run, and you will not get a prior warning message.

Sub CustomMenusFile_Example() 

    Dim vsoUIObject As Visio.UIObject 
    Dim strPath As String

    'Check whether there are custom menus bound to the document.
    If ThisDocument.CustomMenus Is Nothing Then

        'If not, check whether there are custom menus bound to the application.
        If Visio.Application.CustomMenus Is Nothing Then

            'If not, use the Visio built-in menus.
            Set vsoUIObject = Visio.Application.BuiltInMenus 
            MsgBox "Using Built-In Menus", 0 

        Else

            'If there are existing Visio custom menus, use them.
            Set vsoUIObject = Visio.Application.CustomMenus 

            'Save these custom menus to a file. 
            strPath = Visio.Application.Path & "\CustomUI.vsu" 
            vsoUIObject.SaveToFile (strPath) 

            'Set the document to use the existing custom UI. 
            ThisDocument.CustomMenusFile = strPath

            'Get this document's UIObject object.
            Set vsoUIObject = ThisDocument.CustomMenus 

            'Delete the newly created temp file. 
            Kill Visio.Application.Path & "\CustomUI.vsu" 
            ThisDocument.ClearCustomMenus 
            MsgBox "Using Custom Menus", 0 

        End If  

    Else

        'Use the existing custom menus.
        Set vsoUIObject = ThisDocument.CustomMenus
 
    End If  

End Sub

Applies to | Application object | Document object | InvisibleApp object

See Also | CustomMenus property | CustomToolbars property | CustomToolbarsFile property