FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Reading active position the page in a Word-document
Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Reading active position the page in a Word-document
Posted: Sun Oct 11, 2020 09: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

Posts: 99
Joined: Thu Jul 12, 2007 02:02 PM
Re: Reading active position the page in a Word-document
Posted: Sun Oct 11, 2020 05:16 PM
Hello Jack,

try this

Code (fw): Select all Collapse
#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
Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Re: Reading active position the page in a Word-document
Posted: Tue Oct 13, 2020 12:21 PM

Thanks a lot for this help .

Philippe

Continue the discussion