OLE objects in DataWindow objects
The preceding sections discuss the automation interface to
OLE controls and OLE objects. You can also use scripts to change
settings for an OLE object embedded in a DataWindow object, and
you can address properties of the external OLE object.
This section describes how to use the Object property in dot
notation to set DataWindow properties and issue automation commands
for OLE objects in DataWindow objects.
Naming the OLE object
To use dot notation for the OLE object, give the object a
name. You specify the name on the General page in the object’s
property sheet.
Setting properties
You set properties of the OLE container object just as you
do for any object in the DataWindow object. The Object property
of the control is an interface to the objects within the DataWindow
object.
For example, this statement sets the Pointer property of the
object ole_word:
1 |
dw_1.Object.ole_word.Pointer = "Cross!" |
It is important to remember that the compiler does not check
syntax after the Object property. Incorrect property references
cause runtime errors.
For more information about setting properties,
handling errors, and the list of properties for the OLE DWObject,
see the DataWindow Reference.
You cannot create an OLE object in a DataWindow object dynamically
using the CREATE keyword of the Modify function.
The binary data for the OLE object is not compatible with Modify syntax.
Functions and properties
There are four functions you can call for the OLE DWObject.
They have the same effect as for the OLE control. They are:
-
Activate
-
Copy
-
DoVerb
-
UpdateLinksDialog
To call the functions, you use the Object property of the
DataWindow control, just as you do for DataWindow object properties:
1 |
dw_1.Object.ole_word.Activate(InPlace!) |
Four properties that apply to OLE controls in a window also
apply to the OLE DWObject.
Property |
datatype |
Description |
---|---|---|
ClassLongName |
String |
(Read-only) The long name for the server application |
ClassShortName |
String |
(Read-only) The short name for the server application |
LinkItem |
String |
(Read-only) The entire link name of the For example, if the object is linked to C:FILENAME.XLS!A1:B2, |
ObjectData |
Blob |
If the object is embedded, the object If the object is linked, this property contains the link information |
Automation
You can send commands to the OLE server using dot notation.
The syntax involves two Object properties:
-
The Object property of the DataWindow
controlGives you access to DataWindow objects, including the OLE
container DWObject -
The Object property of the OLE DWObject
Gives you access to the automation object
The syntax is:
1 |
<span>dwcontrol</span>.Object.<span>oledwobject</span>.Object.{<span> serverqualifiers</span>. }<span>serverinstruction</span> |
For example, this statement uses the WordBasic Insert function
to add a report title to the beginning of the table of data in the
Word document:
1 |
dw_1.Object.ole_word.Object.application.wordbasic.&<br>   Insert("Report Title " + String(Today())) |