Page History
...
DEFINE_COM CLASS(#VA_WORD.Application) NAME(#WordApp)
Controlling when the Reference is Created
In this example, the Word application is not to start when the LANSA form is executed. To control when Word is started, first define it with a dynamic reference and then assign a reference to it in the Click event of a button.
...
EVTROUTINE HANDLING(#STARTBTN.Click)
SET_REF COM(#WordApp) TO(*CREATE_AS #VA_WORD.application)
ENDROUTINE
Checking if the Reference is Exists
Trying to use any of Word's properties, methods or events before it is started would cause an error. Therefore, initially disable the controls on the form and enable them only when Word has been started. The IF_REF statement is used to check whether a reference has been created to Word. Put this statement in the Click event of the Start Word button:
...