Parameter (Data Type) Description
CreationType
(HMIOLEObjectCreation
Type-)
Defines whether the OLE Element will be newly created or an existing file
will be used:
● HMIOLEObjectCreationTypeDirect: Corresponds to setting "Create
New". This setting is used if you do not specify the parameter.
● HMIOLEObjectCreationTypeByLink: Corresponds to setting "Create
from
File". This creates a copy of the file. Any changes made to the OLE
Element have no effect on the original file. Assign a name to the file via
the "ServerName" parameter.
● HMIOLEObjectCreationTypeByLinkWithReference: Same as above,
except that changes in OLE Element affect the original file. Assign a
name to the file via the "ServerName" parameter.
UseSymbol (Boolean) TRUE if the standard icon for the file type is to be used. Double clicking on
the icon then opens the associated application. The default setting for this
parameter is FALSE.
Example:
In the following example, an OLE Element containing a Wordpad document will be inserted
into the active picture:
Sub AddOLEObjectToActiveDocument()
'VBA124
Dim objOLEObject As HMIOLEObject
Set objOLEObject = ActiveDocument.HMIObjects.AddOLEObject("MS Wordpad Document",
"Wordpad.Document.1")
End Sub
In the following example, the AddOLEObject method will be used and the
"HMIOLEObjectCreationTypeByLink" parameter will be specified:
Sub AddOLEObjectByLink()
'VBA805
Dim objOLEObject As HMIOLEObject
Dim strFilename As String
'
'Add OLEObject by filename. In this case, the filename has to
'contain filename and path.
'Replace the definition of strFilename with a filename with path
'existing on your system
strFilename = Application.ApplicationDataPath & "Test.bmp"
Set objOLEObject = ActiveDocument.HMIObjects.AddOLEObject("OLEObject1", strFilename,
hmiOLEObjectCreationTypeByLink, False)
End Sub
In the following example, the AddOLEObject method will be used and the
"HMIOLEObjectCreationTypeByLinkWithReference" parameter will be specified:
VBA for Automated Configuration
4.4 The object model of the Graphics Designer
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 11/2008,
1723