# Function Reference

# _Word_DocAdd

Adds a new or empty document to the specified Word application

#include <Word.au3>
_Word_DocAdd ( $oAppl [, $iDocumentType = $WdNewBlankDocument [, $sDocumentTemplate = "" [, $bNewTemplate = False]]] )

## Parameters

$oAppl | Word object returned by a preceding call to _Word_Create()
$iDocumentType | [optional] Can be one of the following WdNewDocumentType constants: $WdNewBlankDocument, $WdNewEmailMessage, $WdNewFrameset or $WdNewWebPage (default = $WdNewBlankDocument)
$sDocumentTemplate | [optional] The name of the template to be used for the new document. If this argument is omitted, the Normal template is used (default = "")
$bNewTemplate | [optional] True to open the document as a template (default = False)

## Return Value

Success: | a variable pointing to the new document object.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - $oAppl is not an object 2 - The specified template file does not exist 3 - Error returned by method Documents.Add. @extended is set to the COM error code

## Related

_Word_DocClose, _Word_DocSave, _Word_DocSaveAs

## Example

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

    Local $oWord = _Word_Create()
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAdd Example", _
            "Error creating the Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

    ; Add a new empty document
    _Word_DocAdd($oWord)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAdd Example", "Error creating a new Word document." _
             & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocAdd Example", "A new empty document has successfully been added.")