Page 1 of 1
Reading active position the page in a Word-document
Posted: Sun Oct 11, 2020 9:18 am
by Jack
Hi,
When i instert text in a word document (oWrd:Selection():TypeText("Text to be inserted") , how is it possible to read the vertical or horizontal position in the active page ?
Thanks for your help .
Philippe
Re: Reading active position the page in a Word-document
Posted: Sun Oct 11, 2020 5:16 pm
by MaxP
Hello Jack,
try this
Code: Select all
#include "FiveWin.ch"
#define wdHorizontalPositionRelativeToPage 5
#define wdVerticalPositionRelativeToPage 6
#define wdDoNotSaveChanges 0
FUNCTION MAIN()
LOCAL oWord, oDoc, oSelection, x, y
TRY
oWord := TOleAuto():New( "Word.Application" )
CATCH
oWord := NIL
END
IF oWord <> NIL
oDoc := oWord:Documents:Add()
oWord:Visible := .T.
oSelection := oWord:Selection()
oSelection:TypeText( "This is my text in Word!" )
x := oSelection:Range:Information( wdVerticalPositionRelativeToPage )
y := oSelection:Range:Information( wdHorizontalPositionRelativeToPage )
oWord:Visible := .F.
oDoc:Close( wdDoNotSaveChanges )
oWord:Quit()
MsgStop( ALLTRIM( STR( x ) ) + ", " + ALLTRIM( STR( y ) ) )
ENDIF
RETURN NIL
Regards,
Massimo
Re: Reading active position the page in a Word-document
Posted: Tue Oct 13, 2020 12:21 pm
by Jack
Thanks a lot for this help .
Philippe