Ole4D Scripting, How To

Calling methods of an Ole object

This can be accomplished only from VBScript code (see Evaluating VBS code).

In order to be able to manage the Ole object from VBScript code you have to declare the Ole object. This can be done using OCDeclareObj command .
You can also use the Sender property of the SHost object in event handling methods.

After the declaration of the object, evaluating a simple code line "OleObject.MethodName" with OCRunScript command will execute the Ole object method.

Example
`creating the Ole object
$i:=OCCreaFromProgId (Area1;"Word.Document")
`creating the script host
$i:=OCCreaScriptHost ("WordHost")
`declaring the Ole object in the script host
$i:=OCDeclareObj ("WordHost";"WordDoc1";Area1)
`calling a method of the Ole object (Ms Word method which copies in clipboard the current text selection)
$i:=OCRunScript ("WordHost";"WordDoc1.ActiveWindow.Selection.Copy")
`destroying the script host
OCDestroyScriptHost ("WordHost")
`destroying the Ole object
$i:=OCDestroyObject (Area1)