tole on xp

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

tole on xp

Post 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
Best Regards, Saludos

Falconi Silvio
User avatar
Vikthor
Posts: 271
Joined: Fri Oct 07, 2005 5:20 am
Location: México

Re: tole on xp

Post 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

Vikthor
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

because with tword clas not run ok the possibility to insert a logo into title
Best Regards, Saludos

Falconi Silvio
User avatar
Vikthor
Posts: 271
Joined: Fri Oct 07, 2005 5:20 am
Location: México

Post 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

Vikthor
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

I tryed it last two year the I must use ole ....
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

perhaps I have a old wrong version of tword class
where i can download it ?
Best Regards, Saludos

Falconi Silvio
Post Reply