Function Reference


_Word_DocTableWrite

Writes a one or two dimensional array to a Word table

#include <Word.au3>
_Word_DocTableWrite ( $oRange, ByRef $aArray [, $iIndexBase = Default [, $sDelimiter = Default]] )

Parameters

$oRange Word range object where the table should be inserted
$aArray one or two-dimensional array to be converted to a table.
Can be zero or 1-based
$iIndexBase [optional] Can be 0 or 1 and specifies if the array starts with row 0 or 1 (default = 1)
$sDelimiter [optional] Specifies the character used to separate text into cells (default = @TAB)

Return Value

Success: the Word table object.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 - $oRange is not an object
2 - $aArray is not an array or has more than 2 dimensions
3 - Error occurred when accessing the specified range object. @extended is set to the COM error code
4 - Error occurred when converting the text to a table. @extended is set to the COM error code

Remarks

The array can not contain @CR, @CRLF or @LF in any cell.
If the array contains @TAB characters you have to set parameter $sDelimiter to another character.

Related

_Word_DocTableRead

Example

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

; Create application object
Local $oWord = _Word_Create()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableWrite Example", _
                "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
; Open the test document
Local $oDoc = _Word_DocOpen($oWord, @ScriptDir & "\Extras\Test.doc", Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableWrite Example", _
                "Error opening '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; Write the content of a 0-based two dimensional array to a Word table
Local $asArray[3][3] = [[1, 2, 3], ["a", "b", "c"], ["x", "y", "z"]]
Local $oRange = _Word_DocRangeSet($oDoc, -2)
_Word_DocTableWrite($oRange, $asArray, 0)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableWrite Example", _
                "Error creating the table." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocTableWrite Example", _
                "Table successfully added to the end of the document.")