Hi Jeff
Try this -
Thanks to Enrico (EMG) for help with the WORDREPLACE function
#include "fivewin.ch"
function doctest(oMainWnd,cPath)
local bDoc,cDoc,aSerial := array(10),i := 0,oWord,oDoc,oSel,bString := {|| ''},;
cType := 'Ajax',cManu := 'Allect',nNumber := 10000
cDoc := cGetFile32('*.doc')
bDoc := {|| cDoc }
for i := 1 to len(aSerial)
aSerial[i] := str(nNumber + i)
next
SysRefresh()
TRY
oWord := TOleAuto():New("Word.Application")
oDoc := oWord:Documents:Open(eval(bDoc))
oDoc:Select()
oSel = oWord:Selection
WORDREPLACE( oSel, "#manu#", cManu)
WORDREPLACE( oSel, "#type#", cType)
for i := 1 to len(aSerial)
if i < 10
bString := {|| "#serial" + str(i,1) + "#"}
WORDREPLACE( oSel, eval(bString),aSerial[i])
else
bString := {|| "#serial" + str(i,2) + "#"}
WORDREPLACE( oSel, eval(bString),aSerial[i])
endif
next
SysRefresh()
oWord:Visible := TRUE
CATCH
MsgAlert('Word May Not Be Installed - Cannot Create Document')
lWordError := TRUE
END
return(nil)
//-----------------------------------------------------------------------------------//
STATIC FUNCTION WORDREPLACE( oSel, cSrc, cRpl )
oSel:Start = 0
oSel:End = -1
WHILE oSel:Find:Execute( cSrc )
oSel:Range:Text = cRpl
ENDDO
RETURN NIL
//------------------------------------------------------------------------------------------------------------------//
Cheers
Colin