Specifications
OLE reference
138
Glink: API reference manual Gallagher & Robertson
OLE CALR %v OleID.Method [params]
OLE FREE OleID
The OLE CREATE command allows you to create an instance of an OLE
Automation object. To access a copy of Word for example you would use the
name "Word.Basic".
OLE CONNECT is similar but lets you connect to an object that already exists.
To obtain the value of a property supported by the server you can use the OLE
GET command. To set the value of a property you would use the OLE SET
command.
To invoke a method that doesn't return a value (or that returns a value you don't
need) you use OLE CALL, while to invoke one that does you would use OLE
CALR.
Finally when you are done with the automation server you can use OLE FREE
(this is done automatically when the script terminates if you should forget to do
it yourself).
What this means in practice is best illustrated with an example. Let's imagine
that we have a document in Word format and want to send it to our host
machine. There is no point in sending the file itself in that our host has no way to
extract the text from the document - we need Word for that.
Ole Create Word "Word.Basic"
Ole Call Word.FileOpen "C:\MYDOCS\DOC1.DOC"
Ole Call Word.EditSelectAll
Ole Call Word.EditCopy
Ole Free Word
Binary OFF
Set Transfer ANSI
SndLine "GKRM F"
PutFile FTRAN "*CLP;doc1"
What we are doing here is to ask Word to do the job. The example script first
creates an object in the "Word.Basic" class called "Word" (this is just a name we
choose to represent the object). Now that we have the object we ask it to open
the file, select the entire text and copy it to the clipboard (there is no need to
actually write to a file). We are now done with Word and can free the object.
The rest of the script just uploads the contents of the clipboard to a file called
"doc1" on the host.