FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Consulta Sobre Plantilla Word o Rtf "URGENTE"
Posts: 719
Joined: Fri May 12, 2017 02:50 PM
Consulta Sobre Plantilla Word o Rtf "URGENTE"
Posted: Mon Jun 20, 2022 09:21 PM
Amigos

Muy buenas tardes.

Hace un tiempo atr谩s, logre poder actualizar una plantilla Word, con datos variables y funciono muy bien.

He buscado en el foro algo que se ajuste a lo que necesito, pero no doy.

Pues ahora a esta misma plantilla, necesito incorporar 2 cosas:

- Un codigo QR, generado por dos datos variables (nFicha + cRut).

- Firma del profesional medico que se encuentra en BMP.

Actualmente lo que hace esta funci贸n, es abrir el archivo plantilla Word, reemplazar los campos variables que vienen de una dbf, grabar archivo en disco y al finalizar, imprimir una copia de este documento.

Hoy requiero, despu茅s de poder incorporar el QR y Firma, dar la opci贸n de Imprimir directo o Exportar a PDF.


Necesito resolverlo con urgencia.

Saludos

Antonio

C贸digo Funcionando Actualmente de la Funci贸n:
Code (fw): Select all Collapse
Function Genera_Examen_Altura(nFicha,cTAte,dfec,cNom,cRut,nEdad,cNaci,cOtos,cVis,cPes,cAlt,cPart,cPul,cFres,cEle,cGli,cEva,cHem,cUre,cOri)
聽 聽Local oWord, oSel, oDoc,cOrigen,cDestino,cFile,cSave, Nom1,rut1,naci1,cFilep,cSavep,cDestinop
聽 聽local oActiveDoc,aArrReplace, n

聽 聽 聽IF MsgYesNo( "Desea Generar ARCHIVOS EXAMENES ALTURA / PRE-OCU ?","Ingrese Opci贸n")
聽 聽 聽 聽 聽 聽 聽 聽 Do Case
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Case Tip_Ate1=="A"
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 If (Empty(cNom).or.Empty(cRut).or.Empty(nEdad).or.Empty(cNaci).or.Empty(cOtos).or.Empty(cVis).or.Empty(cPes) .or. Empty(cAlt).or. Empty(cPart) .or. Empty(cPul).or.Empty(cFres).or.Empty(cEva).or.Empty(cEle).or.Empty(cGli))

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Tone(3000)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽MsgInfo("Revise, Faltan Relacionados a Examen de Altura")
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Return .F.
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Endif
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgInfo( "Atenci贸n: " 聽+ CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "En estos momentos Ud.Generar谩 e Imprimir谩" + CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Un Informe de Examen de Altura, por lo que" + CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Esperar hasta que se muestre un aviso con" + CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "El Nombre del Informe Generado, en ese momento" 聽+ CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "El Proceso habra terminado.")

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Case Tip_Ate1=="P"
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 If (Empty(cNom).or.Empty(cRut).or.Empty(nEdad).or.Empty(cNaci).or.Empty(cOtos).or.Empty(cVis).or.Empty(cPes);
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 .or. Empty(cAlt).or. Empty(cPart) .or. Empty(cPul).or.Empty(cFres).or.Empty(cEva).or.Empty(cEle).or.Empty(cGli).or. Empty(cHem).or.Empty(cUre).or.Empty(cOri))


聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Tone(3000)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽MsgInfo("Revise, Faltan Datos Relacionados a Examen de Altura o Pre-Ocupacional")
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Return .F.
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Endif
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgInfo( "Atenci贸n: " 聽+ CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "En estos momentos Ud.Generar谩 e Imprimir谩" + CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Un Informe de Examen de Altura y un Pre-Ocupacional" + CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Esperar hasta que se muestre 2 avisos con El Nombre" + CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "de los Informes Generados, en ese momento El Proceso" 聽+ CRLF +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "habra terminado.")

聽 聽 聽 聽 聽 聽 聽 聽 聽EndCase

聽 聽 聽 聽 聽 聽 聽 聽 cNom:= AnsiToOem(cNom)

聽 聽 聽 聽 聽 聽 聽 聽 nEva:= aScan(aEvaMed, 聽 { | array | array[1] == cEva} )
聽 聽 聽 聽 聽 聽 聽 聽 cEva=aEvaMed[nEva ][2] 聽 // 聽<--- Obtener Nombre del dato del arreglo

聽 聽 聽 聽 聽 聽 聽 聽 cEle:= AnsiToOem(cEle)
聽 聽 聽 聽 聽 聽 聽 聽 cGli:= AnsiToOem(cGli)
聽 聽 聽 聽 聽 聽 聽 聽 cOrigen 聽:= 聽hb_CurDrive()+":\"+curdir()+"\Examenes\Doc_Bases\"
聽 聽 聽 聽 聽 聽 cDestinoa := hb_CurDrive()+":\"+curdir()+"\Examenes\Altura\"
聽 聽 聽 聽 聽 聽 cDestinop := hb_CurDrive()+":\"+curdir()+"\Examenes\Pre-Ocu\"

聽 聽 聽 聽 聽 聽 cFile := "AlturaBase.docx"
聽 聽 聽 聽 聽 聽 cSave := "Altura-"+alltrim(Str(nFicha,10))+"-"+cNom+".doc"

聽 聽 聽 聽 聽 聽 聽 聽 cFilep := "PreocuBase.docx"
聽 聽 聽 聽 聽 聽 cSavep := "Pre-"+alltrim(Str(nFicha,10))+"-"+cNom+".doc"

聽 聽 聽 聽 聽 聽 聽 聽 If lDocAbierto(cOrigen + cFile) 聽 聽 聽//variable que contiene path , nombre, y ext. del fichero modelo o plantilla
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgStop("Documento " + cFile + " est谩 abierto.","Alto")
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Return .f.
聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 聽 聽 */

聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 聽oWord := win_oleCreateObject( "Word.Application")

聽 聽 聽 聽 聽 聽 聽CATCH
聽 聽 聽 聽 聽 聽 聽 聽 聽MsgInfo("Word no est谩 instalado en esta PC. No se puede continuar")
聽 聽 聽 聽 聽 聽 聽 聽 聽Return NIL
聽 聽 聽 聽 聽 聽 聽END

聽 聽 聽 聽 聽 聽 聽TRY
聽 聽 聽 聽 聽 聽 聽 聽 聽oDoc := oWord:Documents:Open(cOrigen + cFile)
聽 聽 聽 聽 聽 聽 聽CATCH
聽 聽 聽 聽 聽 聽 聽 聽 聽MsgInfo("No se puede abrir el archivo plantilla " + cOrigen + cFile)
聽 聽 聽 聽 聽 聽 聽 聽 聽oWord:Quit()
聽 聽 聽 聽 聽 聽 聽 聽 聽Return NIL
聽 聽 聽 聽 聽 聽 聽END
聽 聽 聽 聽 聽 聽 聽oDoc:Select()
聽 聽 聽 聽 聽 聽 聽oSel = oWord:Selection
聽 聽 聽 聽 聽 聽 聽aArrReplace := { { "[nombrepaciente]", AllTrim(cNom) } ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 { "[rut]" 聽 聽 聽 聽 聽 , AllTrim(cRut) } ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 { "[edad]" 聽 聽 聽 聽 聽, AllTrim(Str(nEdad,3)) } ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[naciona]" 聽 聽 聽 , AllTrim(cNaci) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[otos]" 聽 聽 聽 聽 聽, AllTrim(cOtos) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[visi]" 聽 聽 聽 聽 聽, AllTrim(cVis) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[pes]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cPes) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[alt]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cAlt) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[par]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cPart) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[pul]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cPul) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[fr]" 聽 聽 聽 聽 聽 聽 聽 聽, AllTrim(cFres) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[eva]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cEva) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[ekg]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cEle) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[gli]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cGli) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[fate]" 聽 聽 聽 聽 聽, Dtoc(dfec) } }

聽 聽 聽 聽 聽 聽 聽For n:=1 to Len(aArrReplace)
聽 聽 聽 聽 聽 聽 聽 聽 聽Reemplaza_Text_F2( oSel, aArrReplace[n][1], aArrReplace[n][2] )
聽 聽 聽 聽 聽 聽 聽Next n

聽 聽 聽 聽 聽 聽 聽 聽 oWord:ActiveDocument:SaveAs(cDestinoa + cSave)
聽 聽 聽 聽 聽// 聽 聽 oWord:ActiveDocument:PrintOut() 聽 聽 // Habilitar Imprime Dcoumento
聽 聽 聽 聽 聽 聽 oWord:ActiveDocument:Close()




聽 聽 聽 聽 聽 聽 聽SysRefresh()
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgInfo(" Examen de Altura Generado "+cSave)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ** Si Existe Pre-Ocupacional
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 If cTAte = "P"

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 If lDocAbierto(cOrigen + cFilep ) 聽 聽 聽//variable que contiene path , nombre, y ext. del fichero modelo o plantilla
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgStop("Documento " + cFilep + " est谩 abierto.","Alto")
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Return .f.
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 endif

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽oWord := win_oleCreateObject( "Word.Application")

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 CATCH
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽MsgInfo("Word no est谩 instalado en esta PC. No se puede continuar")
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Return NIL
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 END

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 oDoc := oWord:Documents:Open(cOrigen + cFilep )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 CATCH
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgInfo("No se puede abrir el archivo plantilla " + cOrigen + cFilep)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 oWord:Quit()
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Return NIL
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 END

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽* 聽oWord:=.T. 聽 // Para Mostrar

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 oDoc:Select()
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 oSel = oWord:Selection
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 // Crear Matriz de reemplazos
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 aArrReplace := { { "[nombrepaciente]", AllTrim(cNom) } ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[rut]" 聽 聽 聽 聽 聽 , AllTrim(cRut) } ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[edad]" 聽 聽 聽 聽 聽, AllTrim(Str(nEdad,3)) } ,;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[naciona]" 聽 聽 聽 , AllTrim(cNaci) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[pes]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cPes) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[alt]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cAlt) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[par]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cPart) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[ekg]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cEle) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[eva]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cEva) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[gli]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cGli) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[hem]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cHem) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[ure]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cUre) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[ori]" 聽 聽 聽 聽 聽 聽 聽 , AllTrim(cOri) },;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽{ "[fate]" 聽 聽 聽 聽 聽, Dtoc(dfec) } }

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 For n:=1 to Len(aArrReplace)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Reemplaza_Text_F2( oSel, aArrReplace[n][1], aArrReplace[n][2] )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Next n

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 oWord:ActiveDocument:SaveAs(cDestinop + cSavep)
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 // 聽oWord:ActiveDocument:PrintOut() 聽 聽 // Habilitar Para Imprimir
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 oWord:ActiveDocument:Close()



聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 SysRefresh()

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgInfo(" Examen de Pre-Ocupacional Generado "+cSavep)

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 Endif
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ** Fin Pre-Ocupa
聽 聽 聽 聽 聽Endif
Return nil

//---------------------------------------------------//
Static Function Reemplaza_Text_F2( oSel, cSrc, cRpl)
聽 聽 Local wdCollapseEnd:=0
聽 聽 LOCAL oRng := oSel:Content

聽 聽 IF AT( cSrc, oRng:Text ) = 0
聽 聽 聽 聽 RETURN .F.
聽 聽 ENDIF

聽 聽 WHILE oRng:Execute( cSrc )
聽 聽 聽 聽 oRng:Text = cRpl
聽 聽 聽 聽 oRng:Collapse( wdCollapseEnd )
聽 聽 ENDDO

RETURN .T.



// Para Consultar si Archivo Plantilla esta Abierto
Function lDocAbierto(cDocName)
聽 聽 聽 聽 Local FO_EXCLUSIVE := 16
聽 聽 聽 聽 local lOpen:=.f., nHand
聽 聽 聽 聽 聽 If ( nHand := FOPEN(cDocName, FO_EXCLUSIVE ) ) = -1
聽 聽 聽 聽 聽 聽 聽lOpen := .t.
聽 聽 聽 聽 聽 Else
聽 聽 聽 聽 聽 聽 聽FCLOSE( nHand )
聽 聽 聽 聽 聽 Endif
聽 聽 聽 聽 Return lOpen
FWH 22.10 - HARBOUR - PELLES C
Posts: 719
Joined: Fri May 12, 2017 02:50 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Tue Jun 21, 2022 04:09 PM

Amigos.

Buen dia.

Alguna idea?, estoy muy complicado con esta exigencia...

Saludos

Antonio

FWH 22.10 - HARBOUR - PELLES C
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Tue Jun 21, 2022 05:06 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 719
Joined: Fri May 12, 2017 02:50 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Tue Jun 21, 2022 05:39 PM

Maestro Antonio

Buen d铆a, muchas gracias por responder.

Lo que me sugieres, solo tiene relaci贸n con convertir Doc a Pdf, corresponder铆a al ultimo paso de lo que requiero.

Mi prioridad es saber como puedo generar y agregar este c贸digo QR a mi plantilla, adem谩s como puedo agregar un BMP que corresponder a una firma, desde el c贸digo FWH.

Por hoy, tengo esta exigencia con urgencia.

Saludos

Antonio

FWH 22.10 - HARBOUR - PELLES C
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Tue Jun 21, 2022 06:59 PM

Antonio:
Tanto el QR como la firma pueden ser 2 archivos BMP (o cualquier otro formato que elijas).
De esta manera, para armar el archivo RTF final, previamente tienes que tener los dos archivos de im谩genes creados.
Luego, en la parte que quieras del documento, tiene que insertar esos dos archivos.
Por lo que le铆, para insertar una imagen debes inserta el codigo RTF correspondiente, y la imagen, codificada en base64.
Algo de este estilo
{\pict\pngblip\picw10449\pich3280\picwgoal5924\pichgoal1860 hex data}
Hay mucha info en internet al respecto.. Yo nunca lo he hecho pero creo que ese es el camino...
Espero que te de una pista al menos

Posts: 719
Joined: Fri May 12, 2017 02:50 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Tue Jun 21, 2022 07:49 PM
cmsoft wrote:Antonio:
Tanto el QR como la firma pueden ser 2 archivos BMP (o cualquier otro formato que elijas).
De esta manera, para armar el archivo RTF final, previamente tienes que tener los dos archivos de im谩genes creados.
Luego, en la parte que quieras del documento, tiene que insertar esos dos archivos.
Por lo que le铆, para insertar una imagen debes inserta el codigo RTF correspondiente, y la imagen, codificada en base64.
Algo de este estilo
{\pict\pngblip\picw10449\pich3280\picwgoal5924\pichgoal1860 hex data}
Hay mucha info en internet al respecto.. Yo nunca lo he hecho pero creo que ese es el camino...
Espero que te de una pista al menos


Hola Cesar.

Deseo que est茅s muy bien.

Muchas gracias por siempre darme tu ayuda.

Tengo otro link pendiente sobre un tema de verificaci贸n de c贸digo QR, donde me ofreciste tu ayuda y estoy muy agradecido por tu disposici贸n, pero lo tengo pendiente. Pues este posteo que sobre el requerimiento de insertar c贸digo QR, es el origen ya me tiene muy complicado.

Aun cuando el requerimiento c贸digo QR, es muy solicitado, es una tendencia que no podemos evitar, hasta el momento, por todo lo que he le铆do, incluyendo lo que me indicas, no hay forma clara, de donde pueda lograr dar soluci贸n a esto, como me dijo un colega por ac谩 de otro lenguaje de prog, como no lo puedes hacer, aqu铆 es algo muy f谩cil, ah铆 quede dando vueltas.

Me estaba preguntando si puedo reemplazar una variable en una plantilla Word o Rtf, no podr铆a asociar una imagen a esa variables?, quiz谩s la b煤squeda de soluci贸n me haga delirar?

He le铆do mucho en el foro, pero choco contra no saber aplicar o entender que con nuestra herramienta no podre hacerlo, se invierte demasiado tiempo, frente a la necesidad del cliente y la presi贸n que ejerce, amigo, es muy complicado y estresa.

Esperado la ayuda divina, muchos saludos.

Antonio
FWH 22.10 - HARBOUR - PELLES C
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Tue Jun 21, 2022 09:00 PM
https://stackoverflow.com/questions/1490734/programmatically-adding-images-to-rtf-document

I found that most of RTF boxes using the following format:

{\object\objemb{\*\objclass Paint.Picture}\objw2699\objh4799{\*\objdata [hex/bin]}}
When [hex/bin] is large amount of hex strings representing the image format. This way working both for Word rtf, and both for RTF box - so it is more efficient.


Prueba a insertar eso y a ver si te funciona :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Tue Jun 21, 2022 09:03 PM
Otra forma propuesta:

you must change "picwgoa" to "picwgoal" and "pichgoa" to "pichgoal"

string mpic = @"{\pict\pngblip\picw" +
img.Width.ToString() + @"\pich" + img.Height.ToString() +
@"\picwgoal" + width.ToString() + @"\pichgoal" + height.ToString() +
@"\bin " + str + "}";


\emfblip Source of the picture is an EMF (enhanced metafile).
\pngblip Source of the picture is a PNG.
\jpegblip Source of the picture is a JPEG.
\shppict Specifies a Word 97-2000 picture. This is a destination control word.
\nonshppict Specifies that Word 97-2000 has written a {\pict destination that it will not read on input. This keyword is for compatibility with other readers.
\macpict Source of the picture is QuickDraw.
\pmmetafileN Source of the picture is an OS/2 metafile. The N argument identifies the metafile type. The N values are described in the \pmmetafile table below.
\wmetafileN Source of the picture is a Windows metafile. The N argument identifies the metafile type (the default is 1).
\dibitmapN Source of the picture is a Windows device-independent bitmap. The N argument identifies the bitmap type (must equal 0).The information to be included in RTF from a Windows device-independent bitmap is the concatenation of the BITMAPINFO structure followed by the actual pixel data.
\wbitmapN Source of the picture is a Windows device-dependent bitmap. The N argument identifies the bitmap type (must equal 0).The information to be included in RTF from a Windows device-dependent bitmap is the result of the GetBitmapBits function.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Tue Jun 21, 2022 10:12 PM
Antonio:
Tengo otro link pendiente sobre un tema de verificaci贸n de c贸digo QR, donde me ofreciste tu ayuda y estoy muy agradecido por tu disposici贸n, pero lo tengo pendiente. Pues este posteo que sobre el requerimiento de insertar c贸digo QR, es el origen ya me tiene muy complicado.

Esto cuando quieras lo vemos...


Me estaba preguntando si puedo reemplazar una variable en una plantilla Word o Rtf, no podr铆a asociar una imagen a esa variables?, quiz谩s la b煤squeda de soluci贸n me haga delirar?

Si, creo que por aca viene la cosa. Con lo que te escribi贸 en el mensaje anterior Antonio Linares, es como creo que debe ser el proceso

He le铆do mucho en el foro, pero choco contra no saber aplicar o entender que con nuestra herramienta no podre hacerlo, se invierte demasiado tiempo, frente a la necesidad del cliente y la presi贸n que ejerce, amigo, es muy complicado y estresa.

Entiendo que a veces los clientes nos ponen sus tiempos, y eso complica, pero creo que con Fivewin es totalmente posible realizar lo que te piden, solo hay que encontrar la manera.
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Wed Jun 22, 2022 01:30 PM
Antonio, creo que aca esta tu solucion.
En el rtf base tienes que poner donde quieres que ponga la imagen con //IMAGEN// para que pueda reemplazarla.
Como te comente, previamente debes generar el QR en formato bmp y grabarlo en disco
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()
LOCAL oDlg

   DEFINE DIALOG oDlg TITLE "This is a dialog" SIZE 400, 200
   @ 4,  8 BUTTON "Ok" ACTION Merge("C:\FWH\samples\base.rtf","C:\FWH\samples\QR.bmp") 
   ACTIVATE DIALOG oDlg CENTERED 

return nil


*************************************************
** Armar documento rtf
*************************************************
PROCEDURE Merge(cBase,cImg)
LOCAL oWord , oDoc, cText , cDoc , cImgBase64 

cDoc := cBase
cImgBase64 :=  StrToHex(hb_memoread( cImg ) ) 
cText := MEMOREAD(cDoc)
cText := STRTRAN(ctext,"//IMAGEN//",'{\pict\pngblip\picw1000\pich1000\picwgoal1000\pichgoal1000\bin '+cImgBase64+' }')

   if !GrabaArchivo( 'c:\fwh\samples\antonio_nuevo.rtf', cText )
      MsgAlert("Fallo crear documento, verifique que no este en uso" , "Alerta"  )           
      RETURN
   ENDIF
   if   (oWord := WinWordObj() ) == nil
        MsgAlert( "MS Word no instalado" ,  "Alerta" )        
        else
        oDoc = oWord:Documents:Open('c:\fwh21\samples\antonio_nuevo.rtf')
        if oDoc == nil
           MsgAlert("Fallo crear documento, verifique que no este en uso" , "Alerta"  )           
         endif
   endif   
   oDoc:Application:Visible := .t.
RETURN

*****************
** Grabar archivo
FUNCTION GrabaArchivo(cArchivo,cDato)
LOCAL Han, nBytes, nErr
Han := FCreate(cArchivo)
nBytes := FWRITE(Han,cDato,Len(cDato))
nErr := Ferror()
IF nErr <> 0 
   MsgStop("Error " + STR(nErr)+CHR(10)+cArchivo,"Error")
ENDIF
LCLOSE(Han)
RETURN nBytes = Len(cDato)

Espero te sirva
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Wed Jun 22, 2022 03:00 PM
Otra forma, mucho m谩s f谩cil, pero que no te genera un rtf, sino que lo usa y despu茅s te lo muestra en preview, es usando la nueva funcionalidad de Fivewin con print
Code (fw): Select all Collapse
function Imprimir()

   local oPrn, cRtf
   cRtf  := MEMOREAD( "MiRtfBase.rtf" )
   //Aca deber铆as reemplazar el texto variable del rtf

   PRINT oPrn PREVIEW   

   PAGE
      
      @ 1, 1 PRINT TO oPrn TEXT cRtf  SIZE 19,18 CM
      
      @ 19,01 PRINT TO oPrn IMAGE "firma.jpg"  CM
      @ 19,15 PRINT TO oPrn IMAGE "qr.bmp"  CM

   ENDPAGE
   ENDPRINT

return nil
Posts: 719
Joined: Fri May 12, 2017 02:50 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Wed Jun 22, 2022 03:29 PM
Antonio Linares wrote:Otra forma propuesta:

you must change "picwgoa" to "picwgoal" and "pichgoa" to "pichgoal"

string mpic = @"{\pict\pngblip\picw" +
img.Width.ToString() + @"\pich" + img.Height.ToString() +
@"\picwgoal" + width.ToString() + @"\pichgoal" + height.ToString() +
@"\bin " + str + "}";


\emfblip Source of the picture is an EMF (enhanced metafile).
\pngblip Source of the picture is a PNG.
\jpegblip Source of the picture is a JPEG.
\shppict Specifies a Word 97-2000 picture. This is a destination control word.
\nonshppict Specifies that Word 97-2000 has written a {\pict destination that it will not read on input. This keyword is for compatibility with other readers.
\macpict Source of the picture is QuickDraw.
\pmmetafileN Source of the picture is an OS/2 metafile. The N argument identifies the metafile type. The N values are described in the \pmmetafile table below.
\wmetafileN Source of the picture is a Windows metafile. The N argument identifies the metafile type (the default is 1).
\dibitmapN Source of the picture is a Windows device-independent bitmap. The N argument identifies the bitmap type (must equal 0).The information to be included in RTF from a Windows device-independent bitmap is the concatenation of the BITMAPINFO structure followed by the actual pixel data.
\wbitmapN Source of the picture is a Windows device-dependent bitmap. The N argument identifies the bitmap type (must equal 0).The information to be included in RTF from a Windows device-dependent bitmap is the result of the GetBitmapBits function.


Buen dia Maestro Antonio.

Muchas gracias por su ayuda, revisare su informaci贸n.

Saludos.

Antonio
FWH 22.10 - HARBOUR - PELLES C
Posts: 719
Joined: Fri May 12, 2017 02:50 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Wed Jun 22, 2022 03:31 PM
cmsoft wrote:Otra forma, mucho m谩s f谩cil, pero que no te genera un rtf, sino que lo usa y despu茅s te lo muestra en preview, es usando la nueva funcionalidad de Fivewin con print
Code (fw): Select all Collapse
function Imprimir()

聽 聽local oPrn, cRtf
聽 聽cRtf 聽:= MEMOREAD( "MiRtfBase.rtf" )
聽 聽//Aca deber铆as reemplazar el texto variable del rtf

聽 聽PRINT oPrn PREVIEW 聽 

聽 聽PAGE
聽 聽 聽 
聽 聽 聽 @ 1, 1 PRINT TO oPrn TEXT cRtf 聽SIZE 19,18 CM
聽 聽 聽 
聽 聽 聽 @ 19,01 PRINT TO oPrn IMAGE "firma.jpg" 聽CM
聽 聽 聽 @ 19,15 PRINT TO oPrn IMAGE "qr.bmp" 聽CM

聽 聽ENDPAGE
聽 聽ENDPRINT

return nil


Hola Amigo Cesar.

Como estas?

Muy agradecido por disposicion a ayudarme y por todo tu tiempo dedicado.

Probare como resulta lo que me indicas.

Muchos Saludos

Antonio
FWH 22.10 - HARBOUR - PELLES C
Posts: 719
Joined: Fri May 12, 2017 02:50 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Wed Jun 22, 2022 11:34 PM

Hola Amigo Cesar.

Prob茅 tu c贸digo, es algo parecido a lo que ya hab铆a tratado de hacer.

Las plantillas tiene un encabezado y un pie de pagina, pero la lectura que hace MEMOREAD(), de un archivo RTF o Word, es solo el cuerpo, no lee los encabezado ni pie de pagina, es por ello que considere insertar el c贸digo qr y la firma en el archivo que se genera con la plantilla. Definitivamente as铆, no me sirve para las exigencias del cliente.

Por mas que leo buscando soluci贸n, mas me enredo.

Muchos Saludos y muchas gracias.

Antonio

FWH 22.10 - HARBOUR - PELLES C
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Consulta Sobre Plantilla Word o Rtf &quot;URGENTE&quot;
Posted: Thu Jun 23, 2022 01:00 AM

Efectivamente, no toma el encabezado ni pie de p谩gina de un rtf.
Tal vez Mr. Rao pueda decirnos si hay soluci贸n para esto.