Reading active position the page in a Word-document

Post Reply
Jack
Posts: 249
Joined: Wed Jul 11, 2007 11:06 am

Reading active position the page in a Word-document

Post 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
User avatar
MaxP
Posts: 85
Joined: Thu Jul 12, 2007 2:02 pm
Contact:

Re: Reading active position the page in a Word-document

Post 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
Jack
Posts: 249
Joined: Wed Jul 11, 2007 11:06 am

Re: Reading active position the page in a Word-document

Post by Jack »

Thanks a lot for this help .

Philippe
Post Reply