>> loDoc = .oWord.documents.OPEN(tcDocument) >> >> lcText = gc_sdate8 + ' ' + alltrim(gc_userid) + ':' + chr(13) + chr(13) >> >> loRange = loDoc.Range() >> loRange.InsertBefore(lcText) >> >> .oWord.VISIBLE = .T. >> >> .oword.WINDOWSTATE = wdWindowStateMinimize >> .oword.WINDOWSTATE = wdWindowStateMaximize && this automatically makes the window activated >>>>
>#define wdCollapseEnd 0 >#define wdCharacter 1 >oWord = CREATEOBJECT([Word.Application]) > >loDoc = oWord.documents.OPEN(GETFILE()) >oWord.VISIBLE = .T. >lcText = gc_sdate8 + ' ' + alltrim(gc_userid) + ':' + chr(13) + chr(13) >loRange = loDoc.Range() >loRange.Collapse(wdCollapseEnd) >loRange.MoveEnd(wdCharacter, -1 ) >oWord.Selection.TypeText(lcText) >Borislav:
Line 1 Line 2After the operation, it looks like this:
10/3/11 SHIM: Line 1 Line 2The problem is that the cursor is now positioned before the 'L' of 'Line 1'. I want it to be positioned at the beginning of the blank line i.e. before the 2nd chr(13) of the inserted text. My knowledge of automating word is not there. Can you help me?