Hi all,
I am trying to insert some text in a word document from an autoit program.
This is my program is supposed to do.
1. Getting the object of word's current instance (This is OK)
2. Setting a range where the cursor locates (This is OK)
3. Insert some text - It has 2 lines - (This is OK)
4. Formatting thar text. - Change the font, size, make it bold - (This is OK)
5. Moving the cursor to the end of the inserted text and send an enter key press so that i can start typing from a new line. And i need to change the Font.Bold = False (This is NOT OK)
Yeah, the fifth thing is not happening. Here is my code
Local $wObj = ObjGet("","Word.Application") ; Here i got the word object
Local $doc = $wObj.ActiveDocument ; Here i set the current document
Local $range = _Word_DocRangeSet($doc,0) ; Here i set the range form current cursor location.
Local $Text = "This is First Line" & @CRLF & "This is Second Line" ; Text in 2 lines
$range.Text = $Text ; Here i insert the text into word
If Not @error Then ; If there is no error occurred, then
With $range.Font
.Bold = 1 ; I have changed the boldess
.Name = "Rachana" ; changed the font
.Size = 14 ; and the size
EndWith
Else
ConsoleWrite("Something went wrong buddy")
EndIf
$range.SetRange($range.ParagraphEnd, $range.Words.End + 1) ; Here is the problem. I want to move the range to the end of the current range.
Sleep(300) ; A short delay
wObj = 0 ; Terminating the object
Exit
So, somebody please help me to move the range to end of the current range.