MS-Word get line number

MS-Word get line number

Postby Jeff Barnes » Fri Jun 17, 2016 8:21 pm

Is there a way to get a line number for a given text string?

I want to search for <DAT:SIG> and insert a picture where <DAT:SIG> is.

I can do the search with:
Code: Select all  Expand view

FUNCTION WordPicture( oSel, cSrc, cRpl, oWord )
    LOCAL oRng := oSel:Document:Content
     oRng:Find:MatchWildcards:= .t.
        IF AT( cSrc, oRng:Text ) = 0; RETURN .F.; ENDIF
       WHILE oRng:Find:Execute( cSrc )
         oRng:Text = ""
         oRng:Collapse( wdCollapseEnd )
       ENDDO
RETURN .T.
 


And can insert the picture with:
Code: Select all  Expand view

oWord:ActiveDocument:Shapes:AddPicture( cRpl, .T., .T., 1, 1, 150, 80)
 


I can go to a line with:
Code: Select all  Expand view

#define wdGoToAbsolute 1
#define wdGoToLine 3
oword:selection:goto(wdGoToLine, wdGoToAbsolute, nLineNumber)
 


I just need to know how to get the right value for nLineNumber based on the location of <DAT:SIG>.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: MS-Word get line number

Postby cnavarro » Sat Jun 18, 2016 12:31 am

Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: MS-Word get line number

Postby Jeff Barnes » Tue Jun 21, 2016 7:39 pm

Thanks Cristobal.

I will give it a try.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 88 guests