Function Reference


_Word_Create

Connects to an existing Word instance or creates a new Word application object

#include <Word.au3>
_Word_Create ( [$bVisible = True [, $bForceNew = False]] )

Parameters

$bVisible [optional] True specifies that the window will be visible (default)
$bForceNew [optional] True forces to create a new Word instance even if there is already a running instance (default = False)

Return Value

Success: a variable pointing to a Word.Application object. Sets @extended to:
0 - Word was already running
1 - Word was not running or $bForceNew was set to True. Word has been started by this function
Failure: 0 and sets the @error flag to non-zero.
@error: 1 - Error returned by function ObjCreate(). @extended is set to the COM error code

Related

_Word_Quit

Example

#include <MsgBoxConstants.au3>
#include <Word.au3>

; Create a new Word object
_Word_Create()
If @error <> 0 Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_Create Example", _
                "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
If @extended = 1 Then
        MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_Create Example", "MS Word was not running when _Word_Create was called.")
Else
        MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_Create Example", "MS Word was already running when _Word_Create was called.")
EndIf