
Add Method (CustomToolbars Listing)
Description
Creates a new, user-defined toolbar. There is a difference between application-specific and 
picture-specific user-defined toolbars:
● Application-specific toolbar: This is linked to the Graphics Designer and is also only visible 
when all the pictures in the Graphics Designer are closed. "Place the VBA code in the 
document called "GlobalTemplateDocument" or "ProjectTemplateDocument" and use the 
Application property.
● Picture-specific toolbar: Is linked with a specific picture and remains visible as long as the 
picture 
is visible. Place the VBA code in the document called "ThisDocument" for the desired 
picture and use the ActiveDocument property.
syntax
Expression.
Add(Key)
Expression
Necessary. An expression or element which returns an object of the "CustomToolbars" type. 
Parameters
Parameter (Data Type) Description
Key (Variant) Identifies the user-defined toolbar. Use unique 
names for "Key" (e.g. "DocToolbar1")
Example:
In the following example a user-defined toolbar with two icons is created in the active picture. 
These icons are separated by a dividing line:
 
Sub AddDocumentSpecificCustomToolbar()
'VBA115
Dim objToolbar As HMIToolbar
Dim objToolbarItem As HMIToolbarItem
 
Set objToolbar = ActiveDocument.CustomToolbars.Add("DocToolbar")
 
'Add toolbar-items to the userdefined toolbar
Set objToolbarItem = objToolbar.ToolbarItems.InsertToolbarItem(1, "tItem1_1", "My first 
Symbol-Icon")
Set objToolbarItem = objToolbar.ToolbarItems.InsertToolbarItem(3, "tItem1_3", "My second 
Symbol-Icon")
'
'Insert seperatorline between the two tollbaritems
VBA for Automated Configuration
4.4 The object model of the Graphics Designer
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
1708
System Manual, 11/2008,