Reading active position the page in a Word-document

Reading active position the page in a Word-document

Postby Jack » Sun Oct 11, 2020 9:18 am

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

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

Postby MaxP » Sun Oct 11, 2020 5:16 pm

Hello Jack,

try this

Code: Select all  Expand view
#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
User avatar
MaxP
 
Posts: 85
Joined: Thu Jul 12, 2007 2:02 pm

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

Postby Jack » Tue Oct 13, 2020 12:21 pm

Thanks a lot for this help .

Philippe
Jack
 
Posts: 288
Joined: Wed Jul 11, 2007 11:06 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests