Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Positioning the cursor
Message
From
04/10/2011 17:56:49
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 5
OS:
Windows 7
Miscellaneous
Thread ID:
01525412
Message ID:
01525588
Views:
52
>>>>Hi All:
>>>>
>>>>In the following snippet:
>>>>
>>>>
>>>>		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
>>>>
>>>>
>>>>Ths cursor is positioned BEFORE the inserted text. How do I position it AFTER the inserted text?
>>>>
>>>>Thanks,
>>>>
>>>>Yossi
>>>
>>>
>>>Something like this?
>>>
>>>#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:
>>
>>I'm embarrassed that I can't get it right. We're almost there.
>>
>>Before the operation, the document looks like this:
>>
>>
>>Line 1
>>Line 2
>>
>>
>>After the operation, it looks like this:
>>
>>
>>10/3/11 SHIM:
>>
>>Line 1
>>Line 2
>>
>>
>>The 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?
>
>
>
>#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)
>loRange = loDoc.Range()
>loRange.InsertParagraphBefore()
>loRange.Collapse(wdCollapseEnd)
>loRange.MoveEnd(wdCharacter, -1 )
>oWord.Selection.TypeText(lcText)
>
Thanks! That worked.
Previous
Reply
Map
View

Click here to load this message in the networking platform