in the Graphics Designer. With VBA you can therefore run through all objects in one or more
pictures with a loop.
When you have selected objects in the picture, these objects are contained in the "Selection"
listing. Use the "HMIDefaultObjects" listing if you want to change the default settings of the
properties of an object.
To address an object in a picture with VBA, use either the object name, e.g.
"ActiveDocument.HMIObjects("Circle1"), or the index number. "
ActiveDocument.HMIObjects(1)" references for example the first object in the active picture.
Editing objects with VBA
You have the following possibilities for editing objects with VBA:
● Create a new object in a picture
● Delete an existing object
● Copy an existing object
● Group existing objects or cancel the grouping
● Search for objects
● Display or change object properties
When you insert a new object into a picture with VBA, the object behaves in the same way as
if you double-clicked it in the Graphics Designer object palette.
The object is given the predefined property values and is inserted in the top left-hand corner
of the picture.
Access to the object properties is dependent on how you created the object. Two examples
illustrate this:
Example 1:
In this example a circle of the type "HMIObject" is inserted into the current picture. You can
use a VBA object of the "HMIObject" type or all objects in the Graphics Designer. However,
you have to address individual properties of the respective object explicitly via the
"Properties(Index)" property:
Sub AddObject()
'VBA30
Dim objObject As HMIObject
Set objObject = ActiveDocument.HMIObjects.AddHMIObject("CircleAsHMIObject", "HMICircle")
'
'standard-properties (e.g. the position) are available every time:
objObject.Top = 40
objObject.Left = 40
'
'non-standard properties can be accessed using the Properties-collection:
objObject.Properties("FlashBackColor") = True
End Sub
VBA for Automated Configuration
4.3 VBA in the Graphics Designer
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 11/2008,
1607