ApplicationName.ObjectName.Version
Function CreateObject() Foundation
Creates and returns a reference to a COM/ActiveX component.
CreateObject( <cProgID>, [<cServer>] ) --> oAutomationObject | NIL
\\servername
The function returns an object from class AutomationObject. If the object cannot be created, return is NIL. In case CCreateObject() returns NIL, the functions ComLastError() and ComLastMessage() can be used to query the error number and the error message.
The AutomationObject returned can be used to access the methods and properties of the COM/ActiveX component, in the same way as with an ordinary Xbase++ object. Method calls as well as read or write access to a property (instance variable) is routed automatically to the COM/ActiveX component. It makes no difference whether the object is created on the local machine, or whether it is hosted by a server specified in parameter <cServer>.
#pragma library( "ascom10.lib" )
PROCEDURE Main
LOCAL oApp
oApp := CreateObject( "Word.Application" )
IF NIL == oApp
// Word.Application could not be created.
? "Error: ", ComLastError()
? "Description:"
? ComLastMessage()
RETURN
ENDIF
// Access a property of the Word application
? oApp:visible
// Assign a value to a property
oApp:visible := ! oApp:visible
// Call a method
oApp:quit()
// destroy the reference
oApp:destroy()
RETURN
#pragma library( "ascom10.lib" )
PROCEDURE Main
LOCAL oApp
oApp := CreateObject( "Word.Application" )
IF NIL == oApp
// Word.Application could not be created.
? "Error: ", ComLastError()
? "Description:"
? ComLastMessage()
RETURN
ENDIF
// Create an ActiveXObject from the AutomationObject
// returned by the CreateObject() function
oApp := oApp:dynamicCast( ActiveXObject() )
// Set callback code block for "Quit" event
oApp:quit := {|| QOUT("Finished!") }
WAIT "Close Word to execute :quit code block"
// Clean up
oApp:quit()
oApp:destroy()
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.