Parameters
Parameter (Data Type) Description
Position (Long) Defines the position of the user-defined menu
within the menu bar. However, picture-specific
menus are always positioned to the right of
application-specific menus.
Key (Variant) Identifies the user-defined menu. Use unique
names for "Key" (e.g. "DocMenu1")
DefaultLabel (String) The name of the user-defined menu.
Example:
In the following example, a user-defined menu with two menus entries and a submenu with
two
entries will be created in the active picture. The submenu will be visually distinguished by
a dividing line:
Sub CreateDocumentMenus()
'VBA159
Dim objDocMenu As HMIMenu
Dim objMenuItem As HMIMenuItem
Dim objSubMenu As HMIMenuItem
'
Set objDocMenu = ActiveDocument.CustomMenus.InsertMenu(1, "DocMenu1", "Doc_Menu_1")
'
Set objMenuItem = objDocMenu.MenuItems.InsertMenuItem(1, "dmItem1_1", "First MenuItem")
Set objMenuItem = objDocMenu.MenuItems.InsertMenuItem(2, "dmItem1_2", "Second MenuItem")
'
'Insert a dividing rule into custumized menu:
Set objMenuItem = objDocMenu.MenuItems.InsertSeparator(3, "dSeparator1_3")
'
Set objSubMenu = objDocMenu.MenuItems.InsertSubMenu(4, "dSubMenu1_4", "First SubMenu")
'
Set objMenuItem = objSubMenu.SubMenu.InsertMenuItem(5, "dmItem1_5", "First item in sub-
menu")
Set objMenuItem = objSubMenu.SubMenu.InsertMenuItem(6, "dmItem1_6", "Second item in sub-
menu")
End Sub
The diagram shows the generated menu structure.
VBA for Automated Configuration
4.4 The object model of the Graphics Designer
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
1764
System Manual, 11/2008,