WinOle/1009 No exported method

334 views
Skip to first unread message

Itamar M. Lins Jr. Lins

unread,
Feb 8, 2012, 8:24:59 AM2/8/12
to harbou...@googlegroups.com
PROCEDURE MAIN
local x, oWord, cModelo:='C:\FONTES\TESTE\
TESTE.docX'   

aCampos:={}
aadd( aCampos, { 'NOME', "JOSE DA SILVA" } )
aadd( aCampos, { 'CPF',  "550" } )


*function ContratoWord( aCampos )

oWord := Win_OleCreateObject( "Word.Application" )

oDoc := oWord:Documents:Open(cModelo)   

for x:=1 to len( aCampos )
        oWord:Replace( oDoc,'['+aCampos[x,1]+']' ,' " '+aCampos[x,2]+' " ' )
next

oWord:end()

Error WINOLE/1009  No exported method: REPLACE (DOS Error -2147352570)
Called from WIN_OLEAUTO:REPLACE(0)
Called from MAIN(19)

Sintaxe VBA replace() function:
Replace(string,find,replacewith[,start[,count[,compare]]])

Best regards,
Itamar M. Lins Jr.

José M. C. Quintas

unread,
Feb 8, 2012, 8:42:10 AM2/8/12
to harbou...@googlegroups.com
Replace() is VBA function, not method of Word.Application.
 
José M. C. Quintas
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

Rossine

unread,
Feb 8, 2012, 2:08:14 PM2/8/12
to Harbour Users
Itamar,

Try this:

[CODE]

oWord:Visible := .F. //PARA NÃO VISUALIZAR O DOCUMENTO
oDoc := oWord:Documents:Open(cDoc_Temp) //ABRE O WORD
for x=1 to len( aCampos )
oTexto := oDoc:Range()
oFind := oTexto:Get( "Find" )

oFind:Set( "Text", aCampos[x,1] )
oFind:Set( "Forward", .T. )
oFind:Set( "Wrap", INT(1) )
oFind:Set( "Format", .f. )
oFind:Set( "MatchCase", .f. )
oFind:Set( "MatchWholeWord", .f. )
oFind:Set( "MatchWildcards", .f. )
oFind:Set( "MatchSoundsLike", .f. )
oFind:Set( "MatchAllWordForms", .f. )

oFind:Invoke( "Execute")

DO WHILE oFind:Get( "Found" ) // Reemplaza todas las
ocurrencias que coincidan

oTexto:Set( "Text", aCampos[x,2] )
oFind:Invoke( "Execute")
Enddo
next

[END_CODE]

Best Regards,

Rossine.
Reply all
Reply to author
Forward
0 new messages