TRY
oWORD := CREATEOBJECT( "word.Application" )
CATCH
MSGSTOP("L'Application Microsoft WORD n'est pas installée sur cet Ordinateur !" )
RETURN NIL
END
oDoc = oWord:Documents:Open(CFILE )
oDoc:Select()
oSel = oWord:Selection
WORDREPLACE( oSel, "#nom#", ALLTRIM(DNOM))
oWord:ActivePrinter = CNAME
oDoc:PrintOut()
oDoc:Close( 0 )
oWord:Quit()
STATIC FUNCTION WORDREPLACE( oSel, cSrc, cRpl )
oSel:Start = 0
oSel:End = -1
WHILE oSel:Find:Execute( cSrc )
oSel:Range:Text = cRpl
ENDDO
RETURN NIL
FUNCTION WORDREPLACEALL( oSel, cSrc, cRpl )
LOCAL oRng := oSel:Document:Content
IF AT( cSrc, oRng:Text ) = 0; RETURN .F.; ENDIF
WHILE oRng:Find:Execute( cSrc )
oRng:Text = cRpl
oRng:Collapse( wdCollapseEnd )
ENDDO
RETURN .T.
driessen wrote:I got an error that the variable WDCOLLAPSEND doesn't exist.
#define wdCollapseEnd 0
driessen wrote:How can I search for a character, a word or a sentence, using this idea ?
IF oRng:Find:Execute( cString )
// Found!
ENDIF
driessen wrote:Is there any difference between : DO WHILE ..... ENDDO and WHILE ..... ENDDO ?
FUNCTION WORDREPLACERNGALL( oDoc, cSrc, cRpl )
LOCAL lOk := .F.
LOCAL oRng
TRY
oRng = oDoc:StoryRanges[ 7 ]
IF AT( cSrc, oRng:Text ) > 0
WHILE oRng:Find:Execute( cSrc )
oRng:Text = cRpl
oRng = oDoc:StoryRanges[ 7 ]
ENDDO
lOk = .T.
ENDIF
CATCH
END
RETURN lOk
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 108 guests