Hi All,
I got some examples on how to create a word document from autoit but I'm hung up on formatting. Specifically setting up ranges. The example at https://www.autoitscript.com/autoit3/docs/libfunctions/_Word_DocRangeSet.htm isn't helping.
Here is what I am trying to do.
I am creating a document one line at a time and need each insertion to have different formatting. This project I'm using autoit to create an outline. Here is an example of what I want.
1) Title A
Subtitle XX 2) Title B
Subtitle YY
Subtitle ZZ
For starters I am just trying to italicize specific lines or words. Here is a sample of code that I'm working from:
#include <MsgBoxConstants.au3>
#include <Word.au3>
$sFile = @ScriptDir & "\Output\Agenda.doc"
Global $oWord = _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)
Global $oDoc = _Word_DocAdd($oWord)
Global $oRange = _Word_DocRangeSet($oDoc, 0) ; Use current selection
Global $myArray[5] = ["1) Title A", "Subtitle XX", "2) Title B", "Subtitle YY", "Subtitle ZZ" ]
For $i=0 to Ubound($myArray)-1
$oRange.InsertAfter($myArray[$i] & @CRLF)
If StringInStr($myArray[$i],"Subtitle") Then
$oRange.Font.Italic = True
EndIf
Next
The above code makes everything italic when I just want the lines with "Subtitle" in them italic.