#include <Word.au3>
Dim $aFont[3] = ['Arial', 'Calibri', 'Times New Roman']
$iCount = 0
$oWordApp = _WordCreate(@ScriptDir & '\Test.doc')
For $j = 1 To 3
For $i = 5 To 20
If BitAND($i, 1) Then
_WordDocInsertString($oWordApp, 'Этот текст написан ' & $i & ' шрифтом', $i, $aFont[$iCount])
Else
_WordDocInsertString($oWordApp, 'Этот текст написан ' & $i & ' шрифтом', $i, $aFont[$iCount], _
True, True, True)
EndIf
$iCount += 1
If $iCount = 3 Then $iCount = 0
Next
Next
;_WordQuit ($oWordApp, -1)
Func _WordDocInsertString($o_Word, $s_String, $i_FontSize, $s_FontName = 'Times New Roman', _
$f_Underline = False, $f_Bold = False, $f_Italic = False)
Local $o_Doc, $i_CountLine
If Not IsObj($o_Word) Then Return SetError(1)
$o_Doc = _WordDocGetCollection($o_Word, 0)
If @error Then Return SetError(1)
$i_CountLine = _WordDocPropertyGet($o_Doc, 23)
If @error Then Return SetError(1)
With $o_Word.Application.Selection
For $i = 0 To $i_CountLine
.MoveDown
Next
.Font.Name = $s_FontName
.Font.Underline = $f_Underline
.Font.Bold = $f_Bold
.Font.Italic = $f_Italic
.Font.Size = $i_FontSize
EndWith
If StringRight($s_String, 1) <> @CR Then $s_String &= @CR
$o_Doc.Range.insertAfter($s_String)
EndFunc ;==>_WordDocInsertString