Page 1 of 1
tole on xp
Posted: Fri Sep 08, 2006 12:02 pm
by Silvio
this code :
Code: Select all
Function stampa_affidamento()
Local cdoc:= "c:\maga\affida.doc"
oWord = TOleAuto():New( "Word.Application" )
oDoc = oWord:Documents:Open( cDoc )
oDoc:Select()
oSel = oWord:Selection
WORDREPLACE( oSel, "<protocollo>", (oDCom)->NumDoc )
WORDREPLACE( oSel, "<data>", DToC((oDCom)->FecDoc) )
WORDREPLACE( oSel, "<fornitore>", (oDCom)->RazSoc )
WORDREPLACE( oSel, "<servizio>", (oDCom)->Concep )
WORDREPLACE( oSel, "<costo>", Desp_Imp() )
// vederla in video e modificarla e salvarla
oDoc:save("c:\maga\aff_"+(oDCom)->NumDoc+".doc")
*oDoc:save("c:\maga\aff_"+alltrim((oDCom)->RazSoc)+"_"+(oDCom)->NumDoc+"_"+dtos(date())+".doc")
oWord:Visible=.t.
//stampa
*oDoc:PrintOut( .F. )
*oDoc:Close( 0 )
*oWord:Quit()
return nil
it create a doc and replace variables but i make some error and the create the doc with xp wwinord 2003
Why ?
On win 2000 ( office 2000) run ok
Re: tole on xp
Posted: Fri Sep 08, 2006 2:08 pm
by Vikthor
Silvio wrote:this code :
Code: Select all
Function stampa_affidamento()
Local cdoc:= "c:\maga\affida.doc"
oWord = TOleAuto():New( "Word.Application" )
oDoc = oWord:Documents:Open( cDoc )
oDoc:Select()
oSel = oWord:Selection
WORDREPLACE( oSel, "<protocollo>", (oDCom)->NumDoc )
WORDREPLACE( oSel, "<data>", DToC((oDCom)->FecDoc) )
WORDREPLACE( oSel, "<fornitore>", (oDCom)->RazSoc )
WORDREPLACE( oSel, "<servizio>", (oDCom)->Concep )
WORDREPLACE( oSel, "<costo>", Desp_Imp() )
// vederla in video e modificarla e salvarla
oDoc:save("c:\maga\aff_"+(oDCom)->NumDoc+".doc")
*oDoc:save("c:\maga\aff_"+alltrim((oDCom)->RazSoc)+"_"+(oDCom)->NumDoc+"_"+dtos(date())+".doc")
oWord:Visible=.t.
//stampa
*oDoc:PrintOut( .F. )
*oDoc:Close( 0 )
*oWord:Quit()
return nil
it create a doc and replace variables but i make some error and the create the doc with xp wwinord 2003
Why ?
On win 2000 ( office 2000) run ok
Silvio , Why not use TWord Class ?
Code: Select all
METHOD Cotizacion() CLASS TCaptura
LOCAL cCot := GetApp():cRuta+"Template\C"+cTempFile()+".doc"
.
.
.
.
.
cFile := GetApp():cRuta+"Template\Cotiza.doc"
__CopyFile( cFile , cCot )
IF ::oWord:IsVisible()
::oWord:Hide()
ENDIF
::oWord:OpenDoc( cCot )
::oWord:Replace( "[Nom]" , cNombre )
::oWord:Replace( "[Raz]" , cRazon )
::oWord:Replace( "[Dom]" , cDom )
::oWord:Replace( "[Col]" , cCol )
::oWord:Replace( "[CP]" , cCp )
::oWord:Replace( "[Pob]" , cPob )
::oWord:Replace( "[cCod]" , Alltrim( Str( ::aVars[ 2 , 1 ] ) ) )
::oWord:Visualizar()
RETURN NIL
Posted: Fri Sep 08, 2006 2:15 pm
by Silvio
because with tword clas not run ok the possibility to insert a logo into title
Posted: Fri Sep 08, 2006 2:34 pm
by Vikthor
Silvio wrote:because with tword clas not run ok the possibility to insert a logo into title
Silvio :
see this code , it's works fine to me
Method AddImagen()
Code: Select all
oWord := TWord():New() // Instancia la Clase Word
cFileWord := cGetFile32("c:\*.doc") // Buscar el Docuemento
oWord:OpenDoc( cFileWord ) // Abre el Documento
oWord:Visualizar() // Visualizar Word
oWord:Write( cTitulo , "Times New Roman", 20 , .T. , .F. , Rgb( 255 , 0 , 0 ) )
oWord:JustificaDoc( 1 )
oWord:HeaderFooter( 9 ) ; oWord :Write( "Creswin + Word" , "Tahoma", 10 , .F. , .F. )
oWord:AddImagen( 1 , 1 , 50 , 50 , "c:\creswin\skins\creswin.bmp" )
oWord:HeaderFooter( 10 ) ; oWord :Write( "Creswin Support" , "Tahoma", 10 , .T. , .T. , Rgb( 255,255,0) )
oWord:JustificaDoc( 2 )
oWord:HeaderFooter( 0 )
oWord:OpenDataSource("c:\Browse.xls") // Abre el origen de datos para la combinaciĆ³n de correspondencia
oWord:ReplaceField( "#Nombre#", "Nombre" ) // Cambia el Template por el campo de correspondencia
oWord:ReplaceField( "#Domicilio#", "Domicilio" ) // Cambia el Template por el campo de correspondencia
oWord:ReplaceField( "#Colonia#", "Colonia" ) // Cambia el Template por el campo de correspondencia
*oWord:oMailMerge:Set( "Destination" , 0 ) // Nuevo documento
//oWord:oMailMerge:Set( "Destination" , 1 ) // A la impresora
// Descomentar esta parte para probar el envio de Emails
oWord:oMailMerge:Set( "Destination" , 2 ) // Por E-Mail
oWord:oMailMerge:Set( "MailAddressFieldName" , "Email2" ) // Indica el campo que contiene el email
oWord:oMailMerge:Set( "MailAsAttachment" , .T. ) // Como Adjunto o parte del cuerpo TRUE = Adjunto
oWord:oMailMerge:Set( "MailSubject" , "Envio de correspondencia desde ......" )
oWord:oMailMerge:Invoke( "Execute" )
return
Posted: Fri Sep 08, 2006 2:45 pm
by Silvio
I tryed it last two year the I must use ole ....
Posted: Fri Sep 08, 2006 2:47 pm
by Silvio
perhaps I have a old wrong version of tword class
where i can download it ?