In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Word desde Xailer.

Foro público de Xailer en español
Responder
Xevi
Mensajes: 1706
Registrado: Jue Sep 08, 2005 12:58 pm

Word desde Xailer.

Mensaje por Xevi »

Muy buenas...
Álguien tiene algun ejemplo de como utilizar Word desde Xailer...
Cómo... enviar texto, todo o parte... cambiar texto, combinar
correspondencia, imprimir.
Gracias.
Un Saludo,
Xevi.
Rene Flores
Mensajes: 620
Registrado: Jue Mar 23, 2006 2:39 am

Word desde Xailer.

Mensaje por Rene Flores »

// Clase TWord
// Esta clase fue iniciada por Pedro Arribas Lopez
// Se ha de linkar junto con la clase Ole2 de Jose Gimenez, ya que la
// clase OLE original de Fivewin produce un error
//
// Modificaciones y añadidos:
// 22-11-2002 Sebastian Almiron - Se ha añadido el Metodo SayRTF() para poder
// imprimir textos FGET. El metodo devuelve un array de dos posiciones, la
// primera devuelve .t. si el texto cabe dentro del marco especificado y .f.
// si no cabe en el marco o no es un texto FGET. La segunda posición contiene
// una cadena FGET con el texto que no cabe en el marco. De este modo podemos
// decidir que hacer con el resto del texto FGET (Pj.: ponerlo en la siguiente
// pagina.
// 20-11-2002 Sebastian Almiron - Se ha modificado el metodo AddImagen() para
// que coloque la imagen dentro de un cuadro de texto nuevo, de manera que esta
// se pueda colocar en cualquier parte del documento, ya que como estaba originalmente
// siempre se ponia donde estubiera el cursor.
// 30-07-2002 Sebastian Almiron - modificado el metodo CMSAY que ahora hace
// una llamada a ::Say despues de recalcular la posicion x e y
// 7-5-2002 Sebastian Almiron - Se ha incorporado el metodo CheckSpelling() que
// llama al corrector ortografico. Debe tenerse el documento en pantalla. Por
// ejemplo despues de llamar a ::Visualizar().
// 7-5-2002 Sebastian Almiron - Se han incorporados los metodos ::Gotop y
// ::GoBottom()
// 6-5-2002 Sebastian Almiron - Los metodos say, line, etc. ahora pueden
// referirse a la cabecera o al cuerpo principal del documento
// Ello nos permitirá crear el "impreso" sobre la cabecera cuando este
// se repita en muchas hojas, consiguiendo con ello un ahorro
// considerable de tiempo y espacio. El metodo SetHeader() hace que todos
// los metodos de pintado/escritura se redirijan a la cabecera y el metodo
// SetMainDoc() hace que se escriban en el cuerpo principal del documento.
// 6-5-2002 Sebastian Almiron - El metodo tabpredeterminado(ncmpos) es para
// indicar la distancia de los tabuladoores predeterminados
// 6-5-2002 Sebastian Almiron - Existe una nueva propiedad ::oLastsay
// que es el ultimo say mandado al documento, ello nos permitirá darle
// formato, como por ejemplo añadirle tabuladores.
// 6-5-2002 Sebastian Almiron - El metodo TabClearAll(ocuadrotext) elimina
// todos los tabuladores existentes, se le puede pasar de parametro el
// ultimo say (::olastsay), por defecto se refiere al documento.
// 6-5-2002 Sebastian Almiron - El metodo AddTabulador(ocuadrotexto) sirve
// para añadir un tabulador, bien al documento (valor por defecto) o bien
// al ultimo say (::olastsay)
// 6-5-2002 Sebastian Almiron - Se ha añadido el metodo ::Box(), su uso es
// similar al mismo metodo de TPrinter
// 6-5-2002 Sebastian Almiron - Se han añadido los metodos ::SetPortrair() y
// setlandscape() al igual que en TPrinter
// 6-5-2002 Sebastian Almiron - Se ha añadido el metodo ::Protect(password) que
// permite proteger el documento contra cualquier modificacion.
// 6-5-2002 Sebastian Almiron - Se ha modificado el metodo ::startpage() y endpage()
// que producia bajo ciertas circunstancias paginas en blanco,
// ahora se aproxima mas a su uso con TPrinter. En realidad Endpage() no
// hace nada pero lo he dejado por mantener la compatibilidad con TPrinter
// 6-5-2002 Sebastian Almiron - Se ha motificado el metodo ::Say(), ahora se le
// puede indicar la anchura del cuadro de texto, por defecto calcula la anchura
// para ajustarlo al texto. Se le puede pasar la altura del cuadro con ello
// nos permitirá crear cuadros grandes en el que el texto esté separado por
// tabuladores y retornos de carro, evitando tener que crear tantos cuadros
// de texto.
#include "FiveWin.Ch"
#define TAB chr(9)
#define ENTER chr(13)
#define ALI_LEFT 0
#define ALI_CENTER 1
#define ALI_RIGHT 2
#define ALI_JUSTIFY 3
#define LOGPIXELSX 88
#define LOGPIXELSY 90
// Recorders and fields delimiters of GTF structure
#define SP_REG Chr( 5 )
#define SP_FIELD Chr( 7 )
#define TP_FONT Chr( 15 )
#define TP_COLOR Chr( 16 )
#define TP_ALIGN Chr( 17 )
// Indentify and version of GTF files
#define FORMAT_TEXT_TYPE "GTF"
#define FORMAT_TEXT_VERSION "1"
// LA CLASE TWORD
CLASS TWord
DATA OleWord
DATA hdc INIT 0
DATA OleDocs
DATA OleActiveDoc
DATA OleTexto
DATA oselection
DATA cNombreDoc
DATA nLinea,nCol, nPage
DATA nYoffset, nXoffset
DATA lstartpag
DATA oLastSay
METHOD New()
METHOD NewDoc( cNombreDoc )
METHOD OpenDoc( cNombreDoc )
METHOD Write( cTexto, cFuente, cSize, lBold, lShadow, nColor )
METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
METHOD TextBox( nTop, nLeft, nBottom, nRight, lLine, nColor, cTexto, oFuente, nJustify )
METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
METHOD FillRect( aRect, oBrush )
METHOD AddImagen( nTop,nLeft,nBottom,nRight, cImagen ) //bySebastianAlmiron
METHOD Visualizar INLINE OleSetProperty( ::OleWord, "Visible", .t. )
METHOD JustificaDoc( nJustify )
METHOD Replace( cOld,cNew )
METHOD Save()
METHOD StartPage()
METHOD EndPage()
METHOD nHorzRes()
METHOD nHorzSize()
METHOD nVertRes()
METHOD nVertSize()
METHOD nLogPixelX()
METHOD nLogPixelY()
METHOD GetTextHeight( cFont, oFont )
METHOD PrintDoc()
METHOD Preview()
METHOD VistaCompleta()
METHOD End()
METHOD Protect(cpassword) // bySebastianAlmiron
METHOD SetLandScape() // bySebastianAlmiron
METHOD SetPortrait() // bySebastianAlmiron
METHOD Box(ntop, nleft, nbottom, nright) //bySebastianAlmiron
METHOD GetTextWidth(cText, oFont)//bySebastianAlmiron
METHOD addTabulador(ncmpos,ocuadrotext)//bySebastianAlmiron
METHOD TabClearAll(ocuadrotext)//bySebastianAlmiron
METHOD TabPredeterminado(ncmpos)//bySebastianAlmiron
METHOD SetHeader()//bySebastianAlmiron
METHOD SetMainDoc()//bySebastianAlmiron
METHOD Gotop() //bySebastianAlmiron
METHOD GoBottom() //bySebastianAlmiron
METHOD CheckSpelling() //bySebastianAlmiron
METHOD SayRTF( ntop, nleft, ctextFormat, nBottom, nright ) //bySebastianAlmiron
ENDCLASS
METHOD NEW( cDoc )
::OleWord := CreateOleObject( "Word.Application" )
return Self
METHOD NewDoc( cNombreDoc )
::OleDocs := OleGetProperty( ::OleWord, "Documents")
OleInvoke( ::OleDocs,"Add")
::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
::OleTexto := OleGetProperty( ::OleWord, "Selection")
::cNombreDoc := cNombreDoc
::nLinea := 0
::nCol := 0
::nPage := 0
::nYoffset := 0
::nXoffset := 0
::lstartpag := .t.
::oselection := ::OleActiveDoc
return nil
METHOD OpenDoc( cNombreDoc )
::OleDocs := OleGetProperty( ::OleWord, "Documents")
IF FILE( cNombreDoc )
::OleActiveDoc := OleInvoke( ::OleDocs,"Open",cNombreDoc )
ELSE
OleInvoke( ::OleDocs,"Add")
::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
ENDIF
::OleTexto := OleGetProperty( ::OleWord, "Selection")
::cNombreDoc := cNombreDoc
::nLinea := 0
::nCol := 0
::nPage := 0
::nYoffset := 0
::nXoffset := 0
::oselection := ::OleactiveDoc
::lstartpag := .t.
return nil
METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
Local oFont := OleGetProperty( ::OleTexto, "Font")
OleSetProperty( oFont, "Name", oFuente:cFaceName )
OleSetProperty( oFont, "Size", int(oFuente:nHeight) )
OleSetProperty( oFont, "Bold", oFuente:lBold )
if ::nLinea < nLin
OleInvoke( ::OleTexto,"TypeText", chr(13) )
::nLinea:= nLin
::nCol := 0
endif
if ::nCol < nCol
OleInvoke( ::OleTexto,"TypeText", chr(9) )
::nCol:=nCol
endif
OleInvoke( ::OleTexto,"TypeText", cTexto )
OleInvoke( oFont,"Reset" )
release oFont
return nil
METHOD TextBox( nTop, nLeft, nBottom, nRight, lLinea, nColor, cTexto, oFuente, nJustify )
LOCAL oShapes,oCuadro,oFill,oLinea, oFontC, oText, oCuadroText
oShapes := OleGetProperty( ::oselection,"Shapes" )
oCuadro := OleInvoke( oShapes, "AddTextbox", 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop) )
oFill := OleGetProperty( oCuadro, "Fill" )
oFillColor := OleGetProperty( oFill,"ForeColor")
OleSetProperty( oFillColor,"RGB",nColor )
oLinea := OleGetProperty( oCuadro, "Line" )
if lLinea
OleSetProperty( oLinea, "Weight", 1 )
else
OleSetProperty( oLinea, "Transparency",0)
OleSetProperty( oLinea, "Visible",0)
endif
oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
oText := OleGetProperty( oCuadroText, "TextRange" )
oFontC := OleGetProperty( oText, "Font")
OleSetProperty( oFontC, "Name", oFuente:cFaceName )
OleSetProperty( oFontC, "Size", INT(oFuente:nHeight) )
OleSetProperty( oFontC, "Bold", oFuente:lBold )
OleSetProperty( oText, "Text", cTexto )
oParagraph := OleGetProperty( oText, "ParagraphFormat")
OleSetProperty( oParagraph, "Alignment", nJustify )
release oParagraph, OLinea, oFillColor, oFill, oFontC, oText,oCuadroText, oCuadro
return nil
METHOD AddImagen( nTop, nLeft, nBottom, nRight, cImagen )
LOCAL oShapes,oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5, oCuadro6, oCuadro7
oShapes := OleGetProperty( ::oselection,"Shapes" )
oCuadro := OleInvoke( oShapes, "AddTextbox", 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
oLinea := OleGetProperty( oCuadro, "Line" )
OleSetProperty( oLinea, "Transparency",0)
OleSetProperty( oLinea, "Visible",0)
oCuadro2 := OleGetProperty(oCuadro,'Anchor')
oCuadro3 := OleGetProperty(oCuadro2,'ShapeRange')
oCuadro4 := OleGetProperty(oCuadro3,'TextFrame')
oCuadro5 := OleGetProperty(oCuadro4,'TextRange')
oCuadro6 := OleGetProperty(oCuadro5,'InlineShapes')
oCuadro7 := Oleinvoke(oCuadro6, "AddPicture", cImagen,.F.,.T.)
release oShapes, oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5, oCuadro6, oCuadro7
return nil
METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad, naltura )
LOCAL oShapes,oFill,oLine,oCuadroText,oText,oFontC,oParagraph
local nTamFuente := if(oFuente:nHeight > 0, int(oFuente:nHeight + 2.8), int((oFuente:nHeight*-1)+2.8) )
DEFAULT nClrText := nRGB(0,0,0), nBkMode := 2, nPad := 0
DEFAULT nSizeHorz := ::GetTextWidth(ctexto,oFuente)
DEFAULT naltura := if(oFuente:nHeight > 0, oFuente:nHeight + 12, (oFuente:nHeight*-1)+12)
nSizeHorz := nSizeHorz + (nSizeHorz*25/100)
do case
case npad = 1
ncol := ncol - nSizeHorz
npad := 2
case npad = 2
ncol = ncol - (nSizeHorz/2)
npad := 1
endcase
oShapes := OleGetProperty( ::oselection,"Shapes" ) //::OleactiveDoc
oCuadro := OleInvoke( oShapes, "AddTextbox", 1,INT(nCol),INT(nLin),nSizeHorz,naltura )
oFill := OleGetProperty( oCuadro, "Fill" )
oLine := OleGetProperty( oCuadro, "Line" )
oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
oText := OleGetProperty( oCuadroText, "TextRange" )
oFontC := OleGetProperty( oText, "Font")
oParagraph := OleGetProperty( oText, "ParagraphFormat")
OleSetProperty( oParagraph, "Alignment", nPad )
OleSetProperty( oFill, "Transparency",0)
OleSetProperty( oFill, "Visible",0)
OleSetProperty( oLine, "Transparency",0)
OleSetProperty( oLine, "Visible",0)
OleSetProperty( oFontC, "Name", oFuente:cFaceName )
OleSetProperty( oFontC, "Size", nTamfuente ) //INT(oFuente:nHeight*-1) )
OleSetProperty( oFontC, "Bold", oFuente:lBold )
OleSetProperty( oFontC, "Italic", oFuente:lItalic )
OleSetProperty( oText, "Text", cTexto )
OleSetProperty( oCuadroText, "MarginLeft",0)
OleSetProperty( oCuadroText, "MarginRight",0)
::oLastSay := otext
release oFontC,oText,oCuadro,oLine,oFill,oShapes,oParagraph,ocuadrot ext
return NIL
METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad, naltura )
nCol := Max( 0, ( nCol * 10 * ::nHorzRes() / ::nHorzSize() ) - ::nYoffset )
nLin := Max( 0, ( nLin * 10 * ::nVertRes() / ::nVertSize() ) - ::nXoffset )
::Say(nLin,nCol,ctexto,oFutnte,nZizeHorz,nClrText,nBkMode,nP ad,naltura)
return NIL
METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
LOCAL oShapes,oShapLinea, oLinea
if oPen = NIL
DEFINE PEN oPen
endif
oShapes := OleGetProperty( ::oselection ,"Shapes" )
oShapLinea := OleInvoke( oShapes, "AddLine", nLeft,nTop,nRight,nBottom )
oLinea := OleGetProperty( oShapLinea, "Line" )
OleSetProperty( oLinea, "Weight", oPen:nWidth-2 )
oPen:End()
release oLinea,oShapLinea,oShapes
return nil
METHOD FillRect( aRect, oBrush )
LOCAL oShapes,oShapBox, oFill, oFillColor
LOCAL nTop := INT(arect[1])
LOCAL nLeft := INT(arect[2])
LOCAL nWidth := INT(aRect[4]-aRect[2])
LOCAL nHeight := INT(aRect[3]-aRect[1])
oShapes := OleGetProperty( ::oselection,"Shapes" )
oShapBox := OleInvoke( oShapes, "AddShape",1,nLeft,nTop,nWidth,nHeight )
oFill := OleGetproperty( oShapBox,"Fill")
oFillColor := OleGetProperty( oFill,"ForeColor")
OleSetProperty( oFillColor,"RGB",oBrush:nRGBColor )
oBrush:End()
release oFillColor,oFill,oShapBox,oShapes
return nil
METHOD GetTextHeight( cFont, oFont )
return oFont:nHeight
METHOD Write( cTexto, cFuente, nSize, lBold, lShadow, nColor )
Local oFont := OleGetProperty( ::OleTexto, "Font")
OleSetProperty( oFont, "Name", cFuente )
OleSetProperty( oFont, "Size", nSize )
OleSetProperty( oFont, "Bold", lBold )
OleSetProperty( oFont, "ColorIndex",nColor )
OleSetProperty( oFont, "Emboss",lShadow )
OleInvoke( ::OleTexto,"TypeText", cTexto )
OleInvoke( oFont,"Reset" )
release oFont
return nil
METHOD Replace( cOld, cNew )
LOCAL oTexto, oFind, oReplace
oTexto := OleInvoke( ::oselection, "Range" )
oFind := OleGetProperty( oTexto, "Find" )
OleSetProprerty( oFind, "Text", cOld )
OleSetProprerty( oFind, "Forward", .T. )
OleSetProprerty( oFind, "Wrap", INT(1) )
OleSetProprerty( oFind, "Format", .f. )
OleSetProprerty( oFind, "MatchCase", .f. )
OleSetProprerty( oFind, "MatchWholeWord", .f. )
OleSetProprerty( oFind, "MatchWildcards", .f. )
OleSetProprerty( oFind, "MatchSoundsLike", .f. )
OleSetProprerty( oFind, "MatchAllWordForms", .f. )
OleInvoke( oFind, "Execute")
DO WHILE OleGetProprerty( oFind, "Found" )
OleSetProprerty( oTexto, "Text", cNew )
OleInvoke( oFind, "Execute")
Enddo
release oReplace,oFind,oTexto
return nil
METHOD JustificaDoc( nJustify )
LOCAL oParagraph := OleGetProperty( ::Oletexto, "ParagraphFormat")
OleSetProperty( oParagraph, "Alignment", nJustify )
release oParagraph
return nil
METHOD Save()
OleInvoke( ::OleActiveDoc,"SaveAs", ::cNombreDoc )
return nil
METHOD StartPage()
if ::lstartpag = .t.
::lstartpag := .f.
else
OleInvoke(::OleTexto,"EndKey",6,0)
OleInvoke(::OleTexto,"InsertBreak")
OleInvoke(::Oletexto,"GotoNext",1)
::nPage++
::nLinea:=0
::nCol :=0
endif
return nil
METHOD EndPage()
return nil
METHOD PrintDoc()
OleInvoke( ::OleWord, "PrintOut" )
return nil
METHOD Preview()
OleSetProperty( ::OleWord, "PrintPreview",.f.)
OleInvoke( ::OleActiveDoc, "PrintPreview")
::Visualizar()
return nil
METHOD VistaCompleta()
LOCAL oWindow, oView
oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
oView := OleGetProperty( oWindow , "View" )
OleSetProperty( oView,"FullScreen", .T. )
::Visualizar()
release oView
return nil
METHOD nHorzRes()
nRes := 2
return nres
METHOD nHorzSize()
nRes := 1
return nres
METHOD nVertRes()
nRes := 2
return nres
METHOD nVertSize()
nRes := 1
return nres
METHOD nLogPixelY()
LOCAL nPixels := 55.38
return nPixels
METHOD nLogPixelX()
LOCAL nPixels := 55.38
return nPixels
METHOD End()
OleInvoke(::OleWord,"Quit",0)
::OleTexto := NIL
::OleActiveDoc := NIL
::OleDocs := NIL
::Oleword := NIL
OleUninitialize()
return nil
METHOD Protect(cpassword)
OleInvoke( ::OleActiveDoc,"Protect", 2, .F., cpassword )
return
METHOD SetLandScape()
local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
OleSetProperty( oPageSetup,'Orientation','1')
release oPageSetup
return
METHOD SetPortrait()
local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
OleSetProperty( oPageSetup,'Orientation','0')
release oPageSetup
return
METHOD Box( nTop, nLeft, nBottom, nRight )
local oShapes,oShapBox
oShapes := OleGetProperty( ::oselection,"Shapes" )
nRight := nRight - nLeft
nBottom := nBottom - nTop
oShapBox := OleInvoke( oShapes, "AddShape",1,nLeft,nTop,nRight,nBottom )
release oShapBox,oShapes
return nil
METHOD GetTextWidth(cText, oFont)
local nancho
if oFont:nHeight > 0
nancho := (oFont:nHeight/1.6)*len(ctext)
else
nancho :=((oFont:nHeight*-1)/1.6)*len(ctext)
endif
return nancho
METHOD addtabulador(npos, ocuadrotext)
local otabstop, oParagraphFormat
DEFAULT ocuadrotext := ::OleTexto
oParagraphFormat := OleGetProperty(ocuadrotext, 'ParagraphFormat')
otabstop := OleGetProperty(oParagraphFormat, 'TabStops')
OleInvoke(otabstop,'Add',npos)
release oParagraphFormat, otabstop
return nil
METHOD TabClearAll(ocuadrotext)
local oparagraphformat, otabstop
DEFAULT ocuadrotext := ::Oletexto
oparagraphformat := OleGetProperty(ocuadrotext,'ParagraphFormat')
otabstop := OleGetProperty(oParagraphformat, 'TabStops')
OleInvoke(otabstop,'ClearAll')
release oparagraphformat, otabstop
return nil
METHOD TabPredeterminado(npos)
OleSetProperty(::OleactiveDoc,'DefaultTabStop', npos )
return nil
METHOD SetHeader()
local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
local oView := OleGetProperty( oWindow , "View")
OleSetProperty(oView,"SeekView",9)
::oselection := OleGetProperty( ::OleTexto, "HeaderFooter")
release oWindow, oView
return
METHOD SetMainDoc()
local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
local oView := OleGetProperty( oWindow , "View")
OleSetProperty(oView,"SeekView",0)
::oselection := ::OleActiveDoc
release oWindow, oView
return
METHOD Gotop()
OleInvoke(::OleTexto, 'HomeKey', 6)
return
METHOD GoBottom()
OleInvoke(::OleTexto, 'EndKey', 6)
return
METHOD CheckSpelling()
Oleinvoke(::OleActiveDoc, 'CheckSpelling')
return
METHOD SayRTF( nTop,nLeft, cTextFormat, nBottom,nRight )
local cText := "", nPos := 1, nLen := 0, nCrLf, cFormat, cVersion, cType
local afuentes := {}, nColorText := 0
local cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeout
local nJustify, nFont
local oShapes, oCuadro, oFill, oLine, oCuadrotext
local oFont := OleGetProperty( ::OleTexto, "Font")
local aSal := {.f.,''}, lnocabe := .f.
nLen := AT( SP_REG, SubStr( cTextFormat, nPos ) )
cFormat := SubStr( cTextFormat, nPos, nLen - 1 )
nPos += nLen
nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) )
cVersion := SubStr( cTextFormat, nPos, nLen - 1 )
nPos += nLen
if !( cFormat == FORMAT_TEXT_TYPE )
asal[1] := .f.
return asal
endif
do whil .t.
if Substr( cTextFormat, npos, 1 ) == SP_FIELD
nPos += 1
exit
endif
cFacename := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 )
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nPos += nLen
cHeight := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 )
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nPos += nLen
cWidth := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 )
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nPos += nLen
lBold := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nPos += nLen
lItalic := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nPos += nLen
lUnderline := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nPos += nLen
lStrikeOut := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nPos += nLen
aadd( afuentes, {cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeOut})
enddo
oShapes := OleGetProperty( ::oselection,"Shapes" )
oCuadro := OleInvoke( oShapes, "AddTextbox", 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
oFill := OleGetProperty( oCuadro, "Fill" )
OleSetProperty( oFill, "Transparency",0)
OleSetProperty( oFill, "Visible",0)
oLine := OleGetProperty( oCuadro, "Line" )
OleSetProperty( oLine, "Transparency",0)
OleSetProperty( oLine, "Visible",0)
oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
oText := OleGetProperty( oCuadroText, "TextRange" )
OleInvoke(ocuadro,'Select')
do while ( cType := SubStr( cTextFormat, nPos, 1 ) ) != SP_FIELD
if cType == TP_ALIGN .or. cType == TP_FONT .or. cType == TP_COLOR
if cType == TP_ALIGN
njustify := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 ))
::Justificadoc(njustify)
endif
if cType == TP_FONT
nfont := val(SubStr( cTextFormat, nPos + 1, nLen -1 ))
OleSetProperty( oFont, "Name", afuentes[nfont,1] )
OleSetProperty( oFont, "Size", if( val(afuentes[nfont,2]) < 0, val(afuentes[nfont,2])*-1, val(afuentes[nfont,2]) ) )
OleSetProperty( oFont, "Bold", afuentes[nfont,4] )
OleSetProperty( oFont, "Italic", afuentes[nfont,5] )
OleSetProperty( oFont, "Underline", afuentes[nfont,6] )
OleSetProperty( oFont, "StrikeThrough", afuentes[nfont,7] )
endif
if cType == TP_COLOR
ncolortext := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr( cTextFormat, nPos ) ) -1 ))
OleSetProperty( oFont,"Color", ncolortext )
endif
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nPos += nLen
else
nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
nCrLf := At( CRLF, SubStr( cTextFormat, nPos ) )
if nLen == 0
if nCrLf == 0
nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) ) - 1
else
nLen := nCrLf + 1
endif
else
if nCrLf == 0 .or. nCrLf > nLen
do while SubStr( ctextformat, nPos + --nLen - 1, 1 ) > Chr( 32 )
enddo
--nLen
else
nLen := nCRLf + 1
endif
endif
cText = SubStr( cTextFormat, nPos, nLen )
lnocabe := OleGetProperty( oCuadroText, 'Overflowing')
if lnocabe
asal[2] := substr( ctextformat,1, 4 )
asal[2] := asal[2] + substr( ctextformat, 5, At( SP_FIELD, Substr( cTextformat, 5) ))
asal[2] := asal[2] + substr( ctextformat, nPos + nLen)
exit
endif
cText = SubStr( cTextFormat, nPos, nLen )
OleInvoke( ::Oletexto, "Typetext", cText )
nPos += nLen
endif
enddo
OleInvoke( oFont,"Reset" )
release oShapes, oCuadro, oFill, oLine, oCuadrotext, oFont
return asal
--
Xevi
Mensajes: 1706
Registrado: Jue Sep 08, 2005 12:58 pm

Word desde Xailer.

Mensaje por Xevi »

Rene,
"el otro producto" no lo he utilizado... vengo directamente de Clipper
5.2... C3 y finalmente escogí Xailer, por lo que agradecería cualquier
ejemplo que puedas o alguien pueda colgar para ver como puedo aplicarlo a mi
aplicación.
Gracias.
Un saludo,
Xevi.
"Rene Flores" <"rflores[nospam]"@ciber-tec.com> escribió en el mensaje
news:[email=48ce8795@ozsrv2.ozlan.local...]48ce8795@ozsrv2.ozlan.local...[/email]
> Xevi:
>
> La clase TWord de "el otro producto" funciona perfectamente con Xailer,
> porque todo lo hace via OLE.
>
> Saludos
>
> Rene Flores
> http://www.ciber.tec.com
>
> escribió:
>> Muy buenas...
>>
>> Álguien tiene algun ejemplo de como utilizar Word desde Xailer...
>> Cómo... enviar texto, todo o parte... cambiar texto, combinar
>> correspondencia, imprimir.
>>
>> Gracias.
>>
>> Un Saludo,
>> Xevi.
>>
>>
>
>
------------------------------------------------------------ --------------------
> // Clase TWord
> // Esta clase fue iniciada por Pedro Arribas Lopez
> // Se ha de linkar junto con la clase Ole2 de Jose Gimenez, ya que la
> // clase OLE original de Fivewin produce un error
> //
> // Modificaciones y añadidos:
> // 22-11-2002 Sebastian Almiron - Se ha añadido el Metodo SayRTF() para
> poder
> // imprimir textos FGET. El metodo devuelve un array de dos posiciones, la
> // primera devuelve .t. si el texto cabe dentro del marco especificado y
> .f.
> // si no cabe en el marco o no es un texto FGET. La segunda posición
> contiene
> // una cadena FGET con el texto que no cabe en el marco. De este modo
> podemos
> // decidir que hacer con el resto del texto FGET (Pj.: ponerlo en la
> siguiente
> // pagina.
> // 20-11-2002 Sebastian Almiron - Se ha modificado el metodo AddImagen()
> para
> // que coloque la imagen dentro de un cuadro de texto nuevo, de manera que
> esta
> // se pueda colocar en cualquier parte del documento, ya que como estaba
> originalmente
> // siempre se ponia donde estubiera el cursor.
> // 30-07-2002 Sebastian Almiron - modificado el metodo CMSAY que ahora
> hace
> // una llamada a ::Say despues de recalcular la posicion x e y
> // 7-5-2002 Sebastian Almiron - Se ha incorporado el metodo
> CheckSpelling() que
> // llama al corrector ortografico. Debe tenerse el documento en pantalla.
> Por
> // ejemplo despues de llamar a ::Visualizar().
> // 7-5-2002 Sebastian Almiron - Se han incorporados los metodos ::Gotop y
> // ::GoBottom()
> // 6-5-2002 Sebastian Almiron - Los metodos say, line, etc. ahora pueden
> // referirse a la cabecera o al cuerpo principal del documento
> // Ello nos permitirá crear el "impreso" sobre la cabecera cuando este
> // se repita en muchas hojas, consiguiendo con ello un ahorro
> // considerable de tiempo y espacio. El metodo SetHeader() hace que todos
> // los metodos de pintado/escritura se redirijan a la cabecera y el metodo
> // SetMainDoc() hace que se escriban en el cuerpo principal del documento.
> // 6-5-2002 Sebastian Almiron - El metodo tabpredeterminado(ncmpos) es
> para
> // indicar la distancia de los tabuladoores predeterminados
> // 6-5-2002 Sebastian Almiron - Existe una nueva propiedad ::oLastsay
> // que es el ultimo say mandado al documento, ello nos permitirá darle
> // formato, como por ejemplo añadirle tabuladores.
> // 6-5-2002 Sebastian Almiron - El metodo TabClearAll(ocuadrotext) elimina
> // todos los tabuladores existentes, se le puede pasar de parametro el
> // ultimo say (::olastsay), por defecto se refiere al documento.
> // 6-5-2002 Sebastian Almiron - El metodo AddTabulador(ocuadrotexto) sirve
> // para añadir un tabulador, bien al documento (valor por defecto) o bien
> // al ultimo say (::olastsay)
> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo ::Box(), su uso es
> // similar al mismo metodo de TPrinter
> // 6-5-2002 Sebastian Almiron - Se han añadido los metodos ::SetPortrair()
> y
> // setlandscape() al igual que en TPrinter
> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo
> ::Protect(password) que
> // permite proteger el documento contra cualquier modificacion.
> // 6-5-2002 Sebastian Almiron - Se ha modificado el metodo ::startpage() y
> endpage()
> // que producia bajo ciertas circunstancias paginas en blanco,
> // ahora se aproxima mas a su uso con TPrinter. En realidad Endpage() no
> // hace nada pero lo he dejado por mantener la compatibilidad con TPrinter
> // 6-5-2002 Sebastian Almiron - Se ha motificado el metodo ::Say(), ahora
> se le
> // puede indicar la anchura del cuadro de texto, por defecto calcula la
> anchura
> // para ajustarlo al texto. Se le puede pasar la altura del cuadro con
> ello
> // nos permitirá crear cuadros grandes en el que el texto esté separado
> por
> // tabuladores y retornos de carro, evitando tener que crear tantos
> cuadros
> // de texto.
>
> #include "FiveWin.Ch"
> #define TAB chr(9)
> #define ENTER chr(13)
>
> #define ALI_LEFT 0
> #define ALI_CENTER 1
> #define ALI_RIGHT 2
> #define ALI_JUSTIFY 3
>
> #define LOGPIXELSX 88
> #define LOGPIXELSY 90
>
> // Recorders and fields delimiters of GTF structure
>
> #define SP_REG Chr( 5 )
> #define SP_FIELD Chr( 7 )
>
> #define TP_FONT Chr( 15 )
> #define TP_COLOR Chr( 16 )
> #define TP_ALIGN Chr( 17 )
>
> // Indentify and version of GTF files
>
> #define FORMAT_TEXT_TYPE "GTF"
> #define FORMAT_TEXT_VERSION "1"
>
> // LA CLASE TWORD
>
> CLASS TWord
> DATA OleWord
> DATA hdc INIT 0
> DATA OleDocs
> DATA OleActiveDoc
> DATA OleTexto
> DATA oselection
> DATA cNombreDoc
> DATA nLinea,nCol, nPage
> DATA nYoffset, nXoffset
> DATA lstartpag
> DATA oLastSay
>
> METHOD New()
> METHOD NewDoc( cNombreDoc )
> METHOD OpenDoc( cNombreDoc )
> METHOD Write( cTexto, cFuente, cSize, lBold, lShadow, nColor )
> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLine, nColor, cTexto,
> oFuente, nJustify )
> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
> METHOD FillRect( aRect, oBrush )
> METHOD AddImagen( nTop,nLeft,nBottom,nRight, cImagen )
> //bySebastianAlmiron
> METHOD Visualizar INLINE OleSetProperty( ::OleWord, "Visible", .t. )
> METHOD JustificaDoc( nJustify )
> METHOD Replace( cOld,cNew )
> METHOD Save()
> METHOD StartPage()
> METHOD EndPage()
> METHOD nHorzRes()
> METHOD nHorzSize()
> METHOD nVertRes()
> METHOD nVertSize()
> METHOD nLogPixelX()
> METHOD nLogPixelY()
> METHOD GetTextHeight( cFont, oFont )
> METHOD PrintDoc()
> METHOD Preview()
> METHOD VistaCompleta()
> METHOD End()
> METHOD Protect(cpassword) // bySebastianAlmiron
> METHOD SetLandScape() // bySebastianAlmiron
> METHOD SetPortrait() // bySebastianAlmiron
> METHOD Box(ntop, nleft, nbottom, nright) //bySebastianAlmiron
> METHOD GetTextWidth(cText, oFont)//bySebastianAlmiron
> METHOD addTabulador(ncmpos,ocuadrotext)//bySebastianAlmiron
> METHOD TabClearAll(ocuadrotext)//bySebastianAlmiron
> METHOD TabPredeterminado(ncmpos)//bySebastianAlmiron
> METHOD SetHeader()//bySebastianAlmiron
> METHOD SetMainDoc()//bySebastianAlmiron
> METHOD Gotop() //bySebastianAlmiron
> METHOD GoBottom() //bySebastianAlmiron
> METHOD CheckSpelling() //bySebastianAlmiron
> METHOD SayRTF( ntop, nleft, ctextFormat, nBottom, nright )
> //bySebastianAlmiron
> ENDCLASS
>
> METHOD NEW( cDoc )
> ::OleWord := CreateOleObject( "Word.Application" )
> return Self
>
> METHOD NewDoc( cNombreDoc )
> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
> OleInvoke( ::OleDocs,"Add")
> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
> ::cNombreDoc := cNombreDoc
> ::nLinea := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::lstartpag := .t.
> ::oselection := ::OleActiveDoc
> return nil
>
> METHOD OpenDoc( cNombreDoc )
> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
> IF FILE( cNombreDoc )
> ::OleActiveDoc := OleInvoke( ::OleDocs,"Open",cNombreDoc )
> ELSE
> OleInvoke( ::OleDocs,"Add")
> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
> ENDIF
> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
> ::cNombreDoc := cNombreDoc
> ::nLinea := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::oselection := ::OleactiveDoc
> ::lstartpag := .t.
> return nil
>
> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
> Local oFont := OleGetProperty( ::OleTexto, "Font")
> OleSetProperty( oFont, "Name", oFuente:cFaceName )
> OleSetProperty( oFont, "Size", int(oFuente:nHeight) )
> OleSetProperty( oFont, "Bold", oFuente:lBold )
>
> if ::nLinea < nLin
> OleInvoke( ::OleTexto,"TypeText", chr(13) )
> ::nLinea:= nLin
> ::nCol := 0
> endif
> if ::nCol < nCol
> OleInvoke( ::OleTexto,"TypeText", chr(9) )
> ::nCol:=nCol
> endif
>
>
> OleInvoke( ::OleTexto,"TypeText", cTexto )
> OleInvoke( oFont,"Reset" )
> release oFont
> return nil
>
> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLinea, nColor, cTexto,
> oFuente, nJustify )
> LOCAL oShapes,oCuadro,oFill,oLinea, oFontC, oText, oCuadroText
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop) )
> oFill := OleGetProperty( oCuadro, "Fill" )
> oFillColor := OleGetProperty( oFill,"ForeColor")
> OleSetProperty( oFillColor,"RGB",nColor )
>
> oLinea := OleGetProperty( oCuadro, "Line" )
> if lLinea
> OleSetProperty( oLinea, "Weight", 1 )
> else
> OleSetProperty( oLinea, "Transparency",0)
> OleSetProperty( oLinea, "Visible",0)
> endif
>
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> oFontC := OleGetProperty( oText, "Font")
>
> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
> OleSetProperty( oFontC, "Size", INT(oFuente:nHeight) )
> OleSetProperty( oFontC, "Bold", oFuente:lBold )
> OleSetProperty( oText, "Text", cTexto )
>
> oParagraph := OleGetProperty( oText, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nJustify )
>
> release oParagraph, OLinea, oFillColor, oFill, oFontC, oText,oCuadroText,
> oCuadro
> return nil
>
> METHOD AddImagen( nTop, nLeft, nBottom, nRight, cImagen )
>
> LOCAL oShapes,oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
> oCuadro6, oCuadro7
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
> oLinea := OleGetProperty( oCuadro, "Line" )
> OleSetProperty( oLinea, "Transparency",0)
> OleSetProperty( oLinea, "Visible",0)
>
> oCuadro2 := OleGetProperty(oCuadro,'Anchor')
> oCuadro3 := OleGetProperty(oCuadro2,'ShapeRange')
> oCuadro4 := OleGetProperty(oCuadro3,'TextFrame')
> oCuadro5 := OleGetProperty(oCuadro4,'TextRange')
>
> oCuadro6 := OleGetProperty(oCuadro5,'InlineShapes')
> oCuadro7 := Oleinvoke(oCuadro6, "AddPicture", cImagen,.F.,.T.)
>
> release oShapes, oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
> oCuadro6, oCuadro7
> return nil
>
>
> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
> naltura )
> LOCAL oShapes,oFill,oLine,oCuadroText,oText,oFontC,oParagraph
> local nTamFuente := if(oFuente:nHeight > 0, int(oFuente:nHeight + 2.8),
> int((oFuente:nHeight*-1)+2.8) )
>
> DEFAULT nClrText := nRGB(0,0,0), nBkMode := 2, nPad := 0
> DEFAULT nSizeHorz := ::GetTextWidth(ctexto,oFuente)
> DEFAULT naltura := if(oFuente:nHeight > 0, oFuente:nHeight + 12,
> (oFuente:nHeight*-1)+12)
>
> nSizeHorz := nSizeHorz + (nSizeHorz*25/100)
>
> do case
> case npad = 1
> ncol := ncol - nSizeHorz
> npad := 2
> case npad = 2
> ncol = ncol - (nSizeHorz/2)
> npad := 1
> endcase
> oShapes := OleGetProperty( ::oselection,"Shapes" ) //::OleactiveDoc
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nCol),INT(nLin),nSizeHorz,naltura )
> oFill := OleGetProperty( oCuadro, "Fill" )
> oLine := OleGetProperty( oCuadro, "Line" )
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> oFontC := OleGetProperty( oText, "Font")
> oParagraph := OleGetProperty( oText, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nPad )
> OleSetProperty( oFill, "Transparency",0)
> OleSetProperty( oFill, "Visible",0)
> OleSetProperty( oLine, "Transparency",0)
> OleSetProperty( oLine, "Visible",0)
> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
> OleSetProperty( oFontC, "Size", nTamfuente )
> //INT(oFuente:nHeight*-1) )
> OleSetProperty( oFontC, "Bold", oFuente:lBold )
> OleSetProperty( oFontC, "Italic", oFuente:lItalic )
> OleSetProperty( oText, "Text", cTexto )
>
> OleSetProperty( oCuadroText, "MarginLeft",0)
> OleSetProperty( oCuadroText, "MarginRight",0)
>
> ::oLastSay := otext
>
> release oFontC,oText,oCuadro,oLine,oFill,oShapes,oParagraph,ocuadrot ext
>
> return NIL
>
> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
> naltura )
>
> nCol := Max( 0, ( nCol * 10 * ::nHorzRes() / ::nHorzSize() ) -
> ::nYoffset )
> nLin := Max( 0, ( nLin * 10 * ::nVertRes() / ::nVertSize() ) -
> ::nXoffset )
>
> ::Say(nLin,nCol,ctexto,oFutnte,nZizeHorz,nClrText,nBkMode,nP ad,naltura)
>
> return NIL
>
> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
> LOCAL oShapes,oShapLinea, oLinea
> if oPen = NIL
> DEFINE PEN oPen
> endif
>
> oShapes := OleGetProperty( ::oselection ,"Shapes" )
> oShapLinea := OleInvoke( oShapes, "AddLine", nLeft,nTop,nRight,nBottom )
> oLinea := OleGetProperty( oShapLinea, "Line" )
> OleSetProperty( oLinea, "Weight", oPen:nWidth-2 )
> oPen:End()
> release oLinea,oShapLinea,oShapes
>
> return nil
>
> METHOD FillRect( aRect, oBrush )
> LOCAL oShapes,oShapBox, oFill, oFillColor
> LOCAL nTop := INT(arect[1])
> LOCAL nLeft := INT(arect[2])
> LOCAL nWidth := INT(aRect[4]-aRect[2])
> LOCAL nHeight := INT(aRect[3]-aRect[1])
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oShapBox := OleInvoke( oShapes,
> "AddShape",1,nLeft,nTop,nWidth,nHeight )
> oFill := OleGetproperty( oShapBox,"Fill")
> oFillColor := OleGetProperty( oFill,"ForeColor")
> OleSetProperty( oFillColor,"RGB",oBrush:nRGBColor )
> oBrush:End()
>
> release oFillColor,oFill,oShapBox,oShapes
> return nil
>
> METHOD GetTextHeight( cFont, oFont )
> return oFont:nHeight
>
> METHOD Write( cTexto, cFuente, nSize, lBold, lShadow, nColor )
> Local oFont := OleGetProperty( ::OleTexto, "Font")
> OleSetProperty( oFont, "Name", cFuente )
> OleSetProperty( oFont, "Size", nSize )
> OleSetProperty( oFont, "Bold", lBold )
> OleSetProperty( oFont, "ColorIndex",nColor )
> OleSetProperty( oFont, "Emboss",lShadow )
>
> OleInvoke( ::OleTexto,"TypeText", cTexto )
> OleInvoke( oFont,"Reset" )
> release oFont
> return nil
>
> METHOD Replace( cOld, cNew )
> LOCAL oTexto, oFind, oReplace
>
> oTexto := OleInvoke( ::oselection, "Range" )
> oFind := OleGetProperty( oTexto, "Find" )
>
> OleSetProprerty( oFind, "Text", cOld )
> OleSetProprerty( oFind, "Forward", .T. )
> OleSetProprerty( oFind, "Wrap", INT(1) )
> OleSetProprerty( oFind, "Format", .f. )
> OleSetProprerty( oFind, "MatchCase", .f. )
> OleSetProprerty( oFind, "MatchWholeWord", .f. )
> OleSetProprerty( oFind, "MatchWildcards", .f. )
> OleSetProprerty( oFind, "MatchSoundsLike", .f. )
> OleSetProprerty( oFind, "MatchAllWordForms", .f. )
>
> OleInvoke( oFind, "Execute")
> DO WHILE OleGetProprerty( oFind, "Found" )
> OleSetProprerty( oTexto, "Text", cNew )
> OleInvoke( oFind, "Execute")
> Enddo
>
> release oReplace,oFind,oTexto
> return nil
>
> METHOD JustificaDoc( nJustify )
> LOCAL oParagraph := OleGetProperty( ::Oletexto, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nJustify )
> release oParagraph
> return nil
>
> METHOD Save()
> OleInvoke( ::OleActiveDoc,"SaveAs", ::cNombreDoc )
> return nil
>
> METHOD StartPage()
> if ::lstartpag = .t.
> ::lstartpag := .f.
> else
> OleInvoke(::OleTexto,"EndKey",6,0)
> OleInvoke(::OleTexto,"InsertBreak")
> OleInvoke(::Oletexto,"GotoNext",1)
> ::nPage++
> ::nLinea:=0
> ::nCol :=0
> endif
> return nil
>
> METHOD EndPage()
> return nil
>
> METHOD PrintDoc()
> OleInvoke( ::OleWord, "PrintOut" )
> return nil
>
> METHOD Preview()
> OleSetProperty( ::OleWord, "PrintPreview",.f.)
> OleInvoke( ::OleActiveDoc, "PrintPreview")
> ::Visualizar()
> return nil
>
> METHOD VistaCompleta()
> LOCAL oWindow, oView
>
> oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> oView := OleGetProperty( oWindow , "View" )
> OleSetProperty( oView,"FullScreen", .T. )
> ::Visualizar()
> release oView
> return nil
>
> METHOD nHorzRes()
> nRes := 2
> return nres
>
> METHOD nHorzSize()
> nRes := 1
> return nres
>
> METHOD nVertRes()
> nRes := 2
> return nres
>
> METHOD nVertSize()
> nRes := 1
> return nres
>
> METHOD nLogPixelY()
> LOCAL nPixels := 55.38
> return nPixels
>
> METHOD nLogPixelX()
> LOCAL nPixels := 55.38
> return nPixels
>
> METHOD End()
> OleInvoke(::OleWord,"Quit",0)
> ::OleTexto := NIL
> ::OleActiveDoc := NIL
> ::OleDocs := NIL
> ::Oleword := NIL
> OleUninitialize()
> return nil
>
> METHOD Protect(cpassword)
> OleInvoke( ::OleActiveDoc,"Protect", 2, .F., cpassword )
> return
>
> METHOD SetLandScape()
> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
> OleSetProperty( oPageSetup,'Orientation','1')
> release oPageSetup
> return
>
> METHOD SetPortrait()
> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
> OleSetProperty( oPageSetup,'Orientation','0')
> release oPageSetup
> return
>
> METHOD Box( nTop, nLeft, nBottom, nRight )
> local oShapes,oShapBox
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
>
> nRight := nRight - nLeft
> nBottom := nBottom - nTop
>
> oShapBox := OleInvoke( oShapes,
> "AddShape",1,nLeft,nTop,nRight,nBottom )
>
> release oShapBox,oShapes
> return nil
>
> METHOD GetTextWidth(cText, oFont)
> local nancho
> if oFont:nHeight > 0
> nancho := (oFont:nHeight/1.6)*len(ctext)
> else
> nancho :=((oFont:nHeight*-1)/1.6)*len(ctext)
> endif
> return nancho
>
> METHOD addtabulador(npos, ocuadrotext)
> local otabstop, oParagraphFormat
> DEFAULT ocuadrotext := ::OleTexto
> oParagraphFormat := OleGetProperty(ocuadrotext, 'ParagraphFormat')
> otabstop := OleGetProperty(oParagraphFormat, 'TabStops')
> OleInvoke(otabstop,'Add',npos)
> release oParagraphFormat, otabstop
> return nil
>
> METHOD TabClearAll(ocuadrotext)
> local oparagraphformat, otabstop
> DEFAULT ocuadrotext := ::Oletexto
> oparagraphformat := OleGetProperty(ocuadrotext,'ParagraphFormat')
> otabstop := OleGetProperty(oParagraphformat, 'TabStops')
> OleInvoke(otabstop,'ClearAll')
> release oparagraphformat, otabstop
> return nil
>
> METHOD TabPredeterminado(npos)
> OleSetProperty(::OleactiveDoc,'DefaultTabStop', npos )
> return nil
>
> METHOD SetHeader()
> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> local oView := OleGetProperty( oWindow , "View")
> OleSetProperty(oView,"SeekView",9)
> ::oselection := OleGetProperty( ::OleTexto, "HeaderFooter")
> release oWindow, oView
> return
>
> METHOD SetMainDoc()
> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> local oView := OleGetProperty( oWindow , "View")
> OleSetProperty(oView,"SeekView",0)
> ::oselection := ::OleActiveDoc
> release oWindow, oView
> return
>
> METHOD Gotop()
> OleInvoke(::OleTexto, 'HomeKey', 6)
> return
>
> METHOD GoBottom()
> OleInvoke(::OleTexto, 'EndKey', 6)
> return
>
> METHOD CheckSpelling()
> Oleinvoke(::OleActiveDoc, 'CheckSpelling')
> return
>
> METHOD SayRTF( nTop,nLeft, cTextFormat, nBottom,nRight )
> local cText := "", nPos := 1, nLen := 0, nCrLf, cFormat, cVersion, cType
> local afuentes := {}, nColorText := 0
> local cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeout
> local nJustify, nFont
> local oShapes, oCuadro, oFill, oLine, oCuadrotext
> local oFont := OleGetProperty( ::OleTexto, "Font")
> local aSal := {.f.,''}, lnocabe := .f.
>
>
> nLen := AT( SP_REG, SubStr( cTextFormat, nPos ) )
> cFormat := SubStr( cTextFormat, nPos, nLen - 1 )
> nPos += nLen
> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) )
> cVersion := SubStr( cTextFormat, nPos, nLen - 1 )
> nPos += nLen
>
> if !( cFormat == FORMAT_TEXT_TYPE )
> asal[1] := .f.
> return asal
> endif
>
> do whil .t.
>
> if Substr( cTextFormat, npos, 1 ) == SP_FIELD
> nPos += 1
> exit
> endif
>
> cFacename := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
> cHeight := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> cWidth := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lBold := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lItalic := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lUnderline := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lStrikeOut := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> aadd( afuentes, {cFacename, cHeight, cWidth, lBold, lItalic, lUnderline,
> lStrikeOut})
>
> enddo
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
> oFill := OleGetProperty( oCuadro, "Fill" )
> OleSetProperty( oFill, "Transparency",0)
> OleSetProperty( oFill, "Visible",0)
> oLine := OleGetProperty( oCuadro, "Line" )
> OleSetProperty( oLine, "Transparency",0)
> OleSetProperty( oLine, "Visible",0)
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> OleInvoke(ocuadro,'Select')
>
>
> do while ( cType := SubStr( cTextFormat, nPos, 1 ) ) != SP_FIELD
> if cType == TP_ALIGN .or. cType == TP_FONT .or. cType == TP_COLOR
> if cType == TP_ALIGN
> njustify := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 ))
> ::Justificadoc(njustify)
> endif
> if cType == TP_FONT
> nfont := val(SubStr( cTextFormat, nPos + 1, nLen -1 ))
> OleSetProperty( oFont, "Name", afuentes[nfont,1] )
> OleSetProperty( oFont, "Size", if( val(afuentes[nfont,2]) < 0,
> val(afuentes[nfont,2])*-1, val(afuentes[nfont,2]) ) )
> OleSetProperty( oFont, "Bold", afuentes[nfont,4] )
> OleSetProperty( oFont, "Italic", afuentes[nfont,5] )
> OleSetProperty( oFont, "Underline", afuentes[nfont,6] )
> OleSetProperty( oFont, "StrikeThrough", afuentes[nfont,7] )
> endif
> if cType == TP_COLOR
> ncolortext := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 ))
> OleSetProperty( oFont,"Color", ncolortext )
> endif
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
> else
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nCrLf := At( CRLF, SubStr( cTextFormat, nPos ) )
> if nLen == 0
> if nCrLf == 0
> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) ) - 1
> else
> nLen := nCrLf + 1
> endif
> else
> if nCrLf == 0 .or. nCrLf > nLen
> do while SubStr( ctextformat, nPos + --nLen - 1, 1 ) > Chr( 32 )
> enddo
> --nLen
> else
> nLen := nCRLf + 1
> endif
> endif
> cText = SubStr( cTextFormat, nPos, nLen )
>
> lnocabe := OleGetProperty( oCuadroText, 'Overflowing')
> if lnocabe
> asal[2] := substr( ctextformat,1, 4 )
> asal[2] := asal[2] + substr( ctextformat, 5, At( SP_FIELD, Substr(
> cTextformat, 5) ))
> asal[2] := asal[2] + substr( ctextformat, nPos + nLen)
> exit
> endif
>
> cText = SubStr( cTextFormat, nPos, nLen )
> OleInvoke( ::Oletexto, "Typetext", cText )
>
> nPos += nLen
> endif
> enddo
>
>
> OleInvoke( oFont,"Reset" )
> release oShapes, oCuadro, oFill, oLine, oCuadrotext, oFont
> return asal
>
>
>
Xevi
Mensajes: 1706
Registrado: Jue Sep 08, 2005 12:58 pm

Word desde Xailer.

Mensaje por Xevi »

¿Nadie tiene un ejemplo???
No pido nada que sea complicado, sólo una orientación, y así facilitarme el
camino de como utilizar Word desde Xailer.
Un Saludo,
Xevi.
"Xevi" <xevicomas_quitar_esto@gmail.com> escribió en el mensaje
news:[email=48cea8b7@ozsrv2.ozlan.local...]48cea8b7@ozsrv2.ozlan.local...[/email]
> Rene,
>
> "el otro producto" no lo he utilizado... vengo directamente de Clipper
> 5.2... C3 y finalmente escogí Xailer, por lo que agradecería cualquier
> ejemplo que puedas o alguien pueda colgar para ver como puedo aplicarlo a
> mi aplicación.
>
> Gracias.
>
> Un saludo,
> Xevi.
>
> "Rene Flores" <"rflores[nospam]"@ciber-tec.com> escribió en el mensaje
> news:[email=48ce8795@ozsrv2.ozlan.local...]48ce8795@ozsrv2.ozlan.local...[/email]
>> Xevi:
>>
>> La clase TWord de "el otro producto" funciona perfectamente con Xailer,
>> porque todo lo hace via OLE.
>>
>> Saludos
>>
>> Rene Flores
>> http://www.ciber.tec.com
>>
>> escribió:
>>> Muy buenas...
>>>
>>> Álguien tiene algun ejemplo de como utilizar Word desde Xailer...
>>> Cómo... enviar texto, todo o parte... cambiar texto, combinar
>>> correspondencia, imprimir.
>>>
>>> Gracias.
>>>
>>> Un Saludo,
>>> Xevi.
>>>
>>>
>>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> // Clase TWord
>> // Esta clase fue iniciada por Pedro Arribas Lopez
>> // Se ha de linkar junto con la clase Ole2 de Jose Gimenez, ya que la
>> // clase OLE original de Fivewin produce un error
>> //
>> // Modificaciones y añadidos:
>> // 22-11-2002 Sebastian Almiron - Se ha añadido el Metodo SayRTF() para
>> poder
>> // imprimir textos FGET. El metodo devuelve un array de dos posiciones,
>> la
>> // primera devuelve .t. si el texto cabe dentro del marco especificado y
>> .f.
>> // si no cabe en el marco o no es un texto FGET. La segunda posición
>> contiene
>> // una cadena FGET con el texto que no cabe en el marco. De este modo
>> podemos
>> // decidir que hacer con el resto del texto FGET (Pj.: ponerlo en la
>> siguiente
>> // pagina.
>> // 20-11-2002 Sebastian Almiron - Se ha modificado el metodo AddImagen()
>> para
>> // que coloque la imagen dentro de un cuadro de texto nuevo, de manera
>> que esta
>> // se pueda colocar en cualquier parte del documento, ya que como estaba
>> originalmente
>> // siempre se ponia donde estubiera el cursor.
>> // 30-07-2002 Sebastian Almiron - modificado el metodo CMSAY que ahora
>> hace
>> // una llamada a ::Say despues de recalcular la posicion x e y
>> // 7-5-2002 Sebastian Almiron - Se ha incorporado el metodo
>> CheckSpelling() que
>> // llama al corrector ortografico. Debe tenerse el documento en pantalla.
>> Por
>> // ejemplo despues de llamar a ::Visualizar().
>> // 7-5-2002 Sebastian Almiron - Se han incorporados los metodos ::Gotop y
>> // ::GoBottom()
>> // 6-5-2002 Sebastian Almiron - Los metodos say, line, etc. ahora pueden
>> // referirse a la cabecera o al cuerpo principal del documento
>> // Ello nos permitirá crear el "impreso" sobre la cabecera cuando este
>> // se repita en muchas hojas, consiguiendo con ello un ahorro
>> // considerable de tiempo y espacio. El metodo SetHeader() hace que todos
>> // los metodos de pintado/escritura se redirijan a la cabecera y el
>> metodo
>> // SetMainDoc() hace que se escriban en el cuerpo principal del
>> documento.
>> // 6-5-2002 Sebastian Almiron - El metodo tabpredeterminado(ncmpos) es
>> para
>> // indicar la distancia de los tabuladoores predeterminados
>> // 6-5-2002 Sebastian Almiron - Existe una nueva propiedad ::oLastsay
>> // que es el ultimo say mandado al documento, ello nos permitirá darle
>> // formato, como por ejemplo añadirle tabuladores.
>> // 6-5-2002 Sebastian Almiron - El metodo TabClearAll(ocuadrotext)
>> elimina
>> // todos los tabuladores existentes, se le puede pasar de parametro el
>> // ultimo say (::olastsay), por defecto se refiere al documento.
>> // 6-5-2002 Sebastian Almiron - El metodo AddTabulador(ocuadrotexto)
>> sirve
>> // para añadir un tabulador, bien al documento (valor por defecto) o bien
>> // al ultimo say (::olastsay)
>> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo ::Box(), su uso
>> es
>> // similar al mismo metodo de TPrinter
>> // 6-5-2002 Sebastian Almiron - Se han añadido los metodos
>> ::SetPortrair() y
>> // setlandscape() al igual que en TPrinter
>> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo
>> ::Protect(password) que
>> // permite proteger el documento contra cualquier modificacion.
>> // 6-5-2002 Sebastian Almiron - Se ha modificado el metodo ::startpage()
>> y endpage()
>> // que producia bajo ciertas circunstancias paginas en blanco,
>> // ahora se aproxima mas a su uso con TPrinter. En realidad Endpage() no
>> // hace nada pero lo he dejado por mantener la compatibilidad con
>> TPrinter
>> // 6-5-2002 Sebastian Almiron - Se ha motificado el metodo ::Say(), ahora
>> se le
>> // puede indicar la anchura del cuadro de texto, por defecto calcula la
>> anchura
>> // para ajustarlo al texto. Se le puede pasar la altura del cuadro con
>> ello
>> // nos permitirá crear cuadros grandes en el que el texto esté separado
>> por
>> // tabuladores y retornos de carro, evitando tener que crear tantos
>> cuadros
>> // de texto.
>>
>> #include "FiveWin.Ch"
>> #define TAB chr(9)
>> #define ENTER chr(13)
>>
>> #define ALI_LEFT 0
>> #define ALI_CENTER 1
>> #define ALI_RIGHT 2
>> #define ALI_JUSTIFY 3
>>
>> #define LOGPIXELSX 88
>> #define LOGPIXELSY 90
>>
>> // Recorders and fields delimiters of GTF structure
>>
>> #define SP_REG Chr( 5 )
>> #define SP_FIELD Chr( 7 )
>>
>> #define TP_FONT Chr( 15 )
>> #define TP_COLOR Chr( 16 )
>> #define TP_ALIGN Chr( 17 )
>>
>> // Indentify and version of GTF files
>>
>> #define FORMAT_TEXT_TYPE "GTF"
>> #define FORMAT_TEXT_VERSION "1"
>>
>> // LA CLASE TWORD
>>
>> CLASS TWord
>> DATA OleWord
>> DATA hdc INIT 0
>> DATA OleDocs
>> DATA OleActiveDoc
>> DATA OleTexto
>> DATA oselection
>> DATA cNombreDoc
>> DATA nLinea,nCol, nPage
>> DATA nYoffset, nXoffset
>> DATA lstartpag
>> DATA oLastSay
>>
>> METHOD New()
>> METHOD NewDoc( cNombreDoc )
>> METHOD OpenDoc( cNombreDoc )
>> METHOD Write( cTexto, cFuente, cSize, lBold, lShadow, nColor )
>> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
>> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
>> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
>> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLine, nColor, cTexto,
>> oFuente, nJustify )
>> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
>> METHOD FillRect( aRect, oBrush )
>> METHOD AddImagen( nTop,nLeft,nBottom,nRight, cImagen )
>> //bySebastianAlmiron
>> METHOD Visualizar INLINE OleSetProperty( ::OleWord, "Visible", .t. )
>> METHOD JustificaDoc( nJustify )
>> METHOD Replace( cOld,cNew )
>> METHOD Save()
>> METHOD StartPage()
>> METHOD EndPage()
>> METHOD nHorzRes()
>> METHOD nHorzSize()
>> METHOD nVertRes()
>> METHOD nVertSize()
>> METHOD nLogPixelX()
>> METHOD nLogPixelY()
>> METHOD GetTextHeight( cFont, oFont )
>> METHOD PrintDoc()
>> METHOD Preview()
>> METHOD VistaCompleta()
>> METHOD End()
>> METHOD Protect(cpassword) // bySebastianAlmiron
>> METHOD SetLandScape() // bySebastianAlmiron
>> METHOD SetPortrait() // bySebastianAlmiron
>> METHOD Box(ntop, nleft, nbottom, nright) //bySebastianAlmiron
>> METHOD GetTextWidth(cText, oFont)//bySebastianAlmiron
>> METHOD addTabulador(ncmpos,ocuadrotext)//bySebastianAlmiron
>> METHOD TabClearAll(ocuadrotext)//bySebastianAlmiron
>> METHOD TabPredeterminado(ncmpos)//bySebastianAlmiron
>> METHOD SetHeader()//bySebastianAlmiron
>> METHOD SetMainDoc()//bySebastianAlmiron
>> METHOD Gotop() //bySebastianAlmiron
>> METHOD GoBottom() //bySebastianAlmiron
>> METHOD CheckSpelling() //bySebastianAlmiron
>> METHOD SayRTF( ntop, nleft, ctextFormat, nBottom, nright )
>> //bySebastianAlmiron
>> ENDCLASS
>>
>> METHOD NEW( cDoc )
>> ::OleWord := CreateOleObject( "Word.Application" )
>> return Self
>>
>> METHOD NewDoc( cNombreDoc )
>> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
>> OleInvoke( ::OleDocs,"Add")
>> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
>> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
>> ::cNombreDoc := cNombreDoc
>> ::nLinea := 0
>> ::nCol := 0
>> ::nPage := 0
>> ::nYoffset := 0
>> ::nXoffset := 0
>> ::lstartpag := .t.
>> ::oselection := ::OleActiveDoc
>> return nil
>>
>> METHOD OpenDoc( cNombreDoc )
>> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
>> IF FILE( cNombreDoc )
>> ::OleActiveDoc := OleInvoke( ::OleDocs,"Open",cNombreDoc )
>> ELSE
>> OleInvoke( ::OleDocs,"Add")
>> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
>> ENDIF
>> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
>> ::cNombreDoc := cNombreDoc
>> ::nLinea := 0
>> ::nCol := 0
>> ::nPage := 0
>> ::nYoffset := 0
>> ::nXoffset := 0
>> ::oselection := ::OleactiveDoc
>> ::lstartpag := .t.
>> return nil
>>
>> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
>> Local oFont := OleGetProperty( ::OleTexto, "Font")
>> OleSetProperty( oFont, "Name", oFuente:cFaceName )
>> OleSetProperty( oFont, "Size", int(oFuente:nHeight) )
>> OleSetProperty( oFont, "Bold", oFuente:lBold )
>>
>> if ::nLinea < nLin
>> OleInvoke( ::OleTexto,"TypeText", chr(13) )
>> ::nLinea:= nLin
>> ::nCol := 0
>> endif
>> if ::nCol < nCol
>> OleInvoke( ::OleTexto,"TypeText", chr(9) )
>> ::nCol:=nCol
>> endif
>>
>>
>> OleInvoke( ::OleTexto,"TypeText", cTexto )
>> OleInvoke( oFont,"Reset" )
>> release oFont
>> return nil
>>
>> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLinea, nColor, cTexto,
>> oFuente, nJustify )
>> LOCAL oShapes,oCuadro,oFill,oLinea, oFontC, oText, oCuadroText
>>
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>> oCuadro := OleInvoke( oShapes, "AddTextbox",
>> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop) )
>> oFill := OleGetProperty( oCuadro, "Fill" )
>> oFillColor := OleGetProperty( oFill,"ForeColor")
>> OleSetProperty( oFillColor,"RGB",nColor )
>>
>> oLinea := OleGetProperty( oCuadro, "Line" )
>> if lLinea
>> OleSetProperty( oLinea, "Weight", 1 )
>> else
>> OleSetProperty( oLinea, "Transparency",0)
>> OleSetProperty( oLinea, "Visible",0)
>> endif
>>
>> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
>> oText := OleGetProperty( oCuadroText, "TextRange" )
>> oFontC := OleGetProperty( oText, "Font")
>>
>> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
>> OleSetProperty( oFontC, "Size", INT(oFuente:nHeight) )
>> OleSetProperty( oFontC, "Bold", oFuente:lBold )
>> OleSetProperty( oText, "Text", cTexto )
>>
>> oParagraph := OleGetProperty( oText, "ParagraphFormat")
>> OleSetProperty( oParagraph, "Alignment", nJustify )
>>
>> release oParagraph, OLinea, oFillColor, oFill, oFontC, oText,oCuadroText,
>> oCuadro
>> return nil
>>
>> METHOD AddImagen( nTop, nLeft, nBottom, nRight, cImagen )
>>
>> LOCAL oShapes,oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
>> oCuadro6, oCuadro7
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>> oCuadro := OleInvoke( oShapes, "AddTextbox",
>> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
>> oLinea := OleGetProperty( oCuadro, "Line" )
>> OleSetProperty( oLinea, "Transparency",0)
>> OleSetProperty( oLinea, "Visible",0)
>>
>> oCuadro2 := OleGetProperty(oCuadro,'Anchor')
>> oCuadro3 := OleGetProperty(oCuadro2,'ShapeRange')
>> oCuadro4 := OleGetProperty(oCuadro3,'TextFrame')
>> oCuadro5 := OleGetProperty(oCuadro4,'TextRange')
>>
>> oCuadro6 := OleGetProperty(oCuadro5,'InlineShapes')
>> oCuadro7 := Oleinvoke(oCuadro6, "AddPicture", cImagen,.F.,.T.)
>>
>> release oShapes, oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
>> oCuadro6, oCuadro7
>> return nil
>>
>>
>> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
>> naltura )
>> LOCAL oShapes,oFill,oLine,oCuadroText,oText,oFontC,oParagraph
>> local nTamFuente := if(oFuente:nHeight > 0, int(oFuente:nHeight + 2.8),
>> int((oFuente:nHeight*-1)+2.8) )
>>
>> DEFAULT nClrText := nRGB(0,0,0), nBkMode := 2, nPad := 0
>> DEFAULT nSizeHorz := ::GetTextWidth(ctexto,oFuente)
>> DEFAULT naltura := if(oFuente:nHeight > 0, oFuente:nHeight + 12,
>> (oFuente:nHeight*-1)+12)
>>
>> nSizeHorz := nSizeHorz + (nSizeHorz*25/100)
>>
>> do case
>> case npad = 1
>> ncol := ncol - nSizeHorz
>> npad := 2
>> case npad = 2
>> ncol = ncol - (nSizeHorz/2)
>> npad := 1
>> endcase
>> oShapes := OleGetProperty( ::oselection,"Shapes" ) //::OleactiveDoc
>> oCuadro := OleInvoke( oShapes, "AddTextbox",
>> 1,INT(nCol),INT(nLin),nSizeHorz,naltura )
>> oFill := OleGetProperty( oCuadro, "Fill" )
>> oLine := OleGetProperty( oCuadro, "Line" )
>> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
>> oText := OleGetProperty( oCuadroText, "TextRange" )
>> oFontC := OleGetProperty( oText, "Font")
>> oParagraph := OleGetProperty( oText, "ParagraphFormat")
>> OleSetProperty( oParagraph, "Alignment", nPad )
>> OleSetProperty( oFill, "Transparency",0)
>> OleSetProperty( oFill, "Visible",0)
>> OleSetProperty( oLine, "Transparency",0)
>> OleSetProperty( oLine, "Visible",0)
>> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
>> OleSetProperty( oFontC, "Size", nTamfuente )
>> //INT(oFuente:nHeight*-1) )
>> OleSetProperty( oFontC, "Bold", oFuente:lBold )
>> OleSetProperty( oFontC, "Italic", oFuente:lItalic )
>> OleSetProperty( oText, "Text", cTexto )
>>
>> OleSetProperty( oCuadroText, "MarginLeft",0)
>> OleSetProperty( oCuadroText, "MarginRight",0)
>>
>> ::oLastSay := otext
>>
>> release oFontC,oText,oCuadro,oLine,oFill,oShapes,oParagraph,ocuadrot ext
>>
>> return NIL
>>
>> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
>> naltura )
>>
>> nCol := Max( 0, ( nCol * 10 * ::nHorzRes() / ::nHorzSize() ) -
>> ::nYoffset )
>> nLin := Max( 0, ( nLin * 10 * ::nVertRes() / ::nVertSize() ) -
>> ::nXoffset )
>>
>> ::Say(nLin,nCol,ctexto,oFutnte,nZizeHorz,nClrText,nBkMode,nP ad,naltura)
>>
>> return NIL
>>
>> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
>> LOCAL oShapes,oShapLinea, oLinea
>> if oPen = NIL
>> DEFINE PEN oPen
>> endif
>>
>> oShapes := OleGetProperty( ::oselection ,"Shapes" )
>> oShapLinea := OleInvoke( oShapes, "AddLine", nLeft,nTop,nRight,nBottom )
>> oLinea := OleGetProperty( oShapLinea, "Line" )
>> OleSetProperty( oLinea, "Weight", oPen:nWidth-2 )
>> oPen:End()
>> release oLinea,oShapLinea,oShapes
>>
>> return nil
>>
>> METHOD FillRect( aRect, oBrush )
>> LOCAL oShapes,oShapBox, oFill, oFillColor
>> LOCAL nTop := INT(arect[1])
>> LOCAL nLeft := INT(arect[2])
>> LOCAL nWidth := INT(aRect[4]-aRect[2])
>> LOCAL nHeight := INT(aRect[3]-aRect[1])
>>
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>> oShapBox := OleInvoke( oShapes,
>> "AddShape",1,nLeft,nTop,nWidth,nHeight )
>> oFill := OleGetproperty( oShapBox,"Fill")
>> oFillColor := OleGetProperty( oFill,"ForeColor")
>> OleSetProperty( oFillColor,"RGB",oBrush:nRGBColor )
>> oBrush:End()
>>
>> release oFillColor,oFill,oShapBox,oShapes
>> return nil
>>
>> METHOD GetTextHeight( cFont, oFont )
>> return oFont:nHeight
>>
>> METHOD Write( cTexto, cFuente, nSize, lBold, lShadow, nColor )
>> Local oFont := OleGetProperty( ::OleTexto, "Font")
>> OleSetProperty( oFont, "Name", cFuente )
>> OleSetProperty( oFont, "Size", nSize )
>> OleSetProperty( oFont, "Bold", lBold )
>> OleSetProperty( oFont, "ColorIndex",nColor )
>> OleSetProperty( oFont, "Emboss",lShadow )
>>
>> OleInvoke( ::OleTexto,"TypeText", cTexto )
>> OleInvoke( oFont,"Reset" )
>> release oFont
>> return nil
>>
>> METHOD Replace( cOld, cNew )
>> LOCAL oTexto, oFind, oReplace
>>
>> oTexto := OleInvoke( ::oselection, "Range" )
>> oFind := OleGetProperty( oTexto, "Find" )
>>
>> OleSetProprerty( oFind, "Text", cOld )
>> OleSetProprerty( oFind, "Forward", .T. )
>> OleSetProprerty( oFind, "Wrap", INT(1) )
>> OleSetProprerty( oFind, "Format", .f. )
>> OleSetProprerty( oFind, "MatchCase", .f. )
>> OleSetProprerty( oFind, "MatchWholeWord", .f. )
>> OleSetProprerty( oFind, "MatchWildcards", .f. )
>> OleSetProprerty( oFind, "MatchSoundsLike", .f. )
>> OleSetProprerty( oFind, "MatchAllWordForms", .f. )
>>
>> OleInvoke( oFind, "Execute")
>> DO WHILE OleGetProprerty( oFind, "Found" )
>> OleSetProprerty( oTexto, "Text", cNew )
>> OleInvoke( oFind, "Execute")
>> Enddo
>>
>> release oReplace,oFind,oTexto
>> return nil
>>
>> METHOD JustificaDoc( nJustify )
>> LOCAL oParagraph := OleGetProperty( ::Oletexto, "ParagraphFormat")
>> OleSetProperty( oParagraph, "Alignment", nJustify )
>> release oParagraph
>> return nil
>>
>> METHOD Save()
>> OleInvoke( ::OleActiveDoc,"SaveAs", ::cNombreDoc )
>> return nil
>>
>> METHOD StartPage()
>> if ::lstartpag = .t.
>> ::lstartpag := .f.
>> else
>> OleInvoke(::OleTexto,"EndKey",6,0)
>> OleInvoke(::OleTexto,"InsertBreak")
>> OleInvoke(::Oletexto,"GotoNext",1)
>> ::nPage++
>> ::nLinea:=0
>> ::nCol :=0
>> endif
>> return nil
>>
>> METHOD EndPage()
>> return nil
>>
>> METHOD PrintDoc()
>> OleInvoke( ::OleWord, "PrintOut" )
>> return nil
>>
>> METHOD Preview()
>> OleSetProperty( ::OleWord, "PrintPreview",.f.)
>> OleInvoke( ::OleActiveDoc, "PrintPreview")
>> ::Visualizar()
>> return nil
>>
>> METHOD VistaCompleta()
>> LOCAL oWindow, oView
>>
>> oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
>> oView := OleGetProperty( oWindow , "View" )
>> OleSetProperty( oView,"FullScreen", .T. )
>> ::Visualizar()
>> release oView
>> return nil
>>
>> METHOD nHorzRes()
>> nRes := 2
>> return nres
>>
>> METHOD nHorzSize()
>> nRes := 1
>> return nres
>>
>> METHOD nVertRes()
>> nRes := 2
>> return nres
>>
>> METHOD nVertSize()
>> nRes := 1
>> return nres
>>
>> METHOD nLogPixelY()
>> LOCAL nPixels := 55.38
>> return nPixels
>>
>> METHOD nLogPixelX()
>> LOCAL nPixels := 55.38
>> return nPixels
>>
>> METHOD End()
>> OleInvoke(::OleWord,"Quit",0)
>> ::OleTexto := NIL
>> ::OleActiveDoc := NIL
>> ::OleDocs := NIL
>> ::Oleword := NIL
>> OleUninitialize()
>> return nil
>>
>> METHOD Protect(cpassword)
>> OleInvoke( ::OleActiveDoc,"Protect", 2, .F., cpassword )
>> return
>>
>> METHOD SetLandScape()
>> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
>> OleSetProperty( oPageSetup,'Orientation','1')
>> release oPageSetup
>> return
>>
>> METHOD SetPortrait()
>> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
>> OleSetProperty( oPageSetup,'Orientation','0')
>> release oPageSetup
>> return
>>
>> METHOD Box( nTop, nLeft, nBottom, nRight )
>> local oShapes,oShapBox
>>
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>>
>> nRight := nRight - nLeft
>> nBottom := nBottom - nTop
>>
>> oShapBox := OleInvoke( oShapes,
>> "AddShape",1,nLeft,nTop,nRight,nBottom )
>>
>> release oShapBox,oShapes
>> return nil
>>
>> METHOD GetTextWidth(cText, oFont)
>> local nancho
>> if oFont:nHeight > 0
>> nancho := (oFont:nHeight/1.6)*len(ctext)
>> else
>> nancho :=((oFont:nHeight*-1)/1.6)*len(ctext)
>> endif
>> return nancho
>>
>> METHOD addtabulador(npos, ocuadrotext)
>> local otabstop, oParagraphFormat
>> DEFAULT ocuadrotext := ::OleTexto
>> oParagraphFormat := OleGetProperty(ocuadrotext, 'ParagraphFormat')
>> otabstop := OleGetProperty(oParagraphFormat, 'TabStops')
>> OleInvoke(otabstop,'Add',npos)
>> release oParagraphFormat, otabstop
>> return nil
>>
>> METHOD TabClearAll(ocuadrotext)
>> local oparagraphformat, otabstop
>> DEFAULT ocuadrotext := ::Oletexto
>> oparagraphformat := OleGetProperty(ocuadrotext,'ParagraphFormat')
>> otabstop := OleGetProperty(oParagraphformat, 'TabStops')
>> OleInvoke(otabstop,'ClearAll')
>> release oparagraphformat, otabstop
>> return nil
>>
>> METHOD TabPredeterminado(npos)
>> OleSetProperty(::OleactiveDoc,'DefaultTabStop', npos )
>> return nil
>>
>> METHOD SetHeader()
>> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
>> local oView := OleGetProperty( oWindow , "View")
>> OleSetProperty(oView,"SeekView",9)
>> ::oselection := OleGetProperty( ::OleTexto, "HeaderFooter")
>> release oWindow, oView
>> return
>>
>> METHOD SetMainDoc()
>> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
>> local oView := OleGetProperty( oWindow , "View")
>> OleSetProperty(oView,"SeekView",0)
>> ::oselection := ::OleActiveDoc
>> release oWindow, oView
>> return
>>
>> METHOD Gotop()
>> OleInvoke(::OleTexto, 'HomeKey', 6)
>> return
>>
>> METHOD GoBottom()
>> OleInvoke(::OleTexto, 'EndKey', 6)
>> return
>>
>> METHOD CheckSpelling()
>> Oleinvoke(::OleActiveDoc, 'CheckSpelling')
>> return
>>
>> METHOD SayRTF( nTop,nLeft, cTextFormat, nBottom,nRight )
>> local cText := "", nPos := 1, nLen := 0, nCrLf, cFormat, cVersion, cType
>> local afuentes := {}, nColorText := 0
>> local cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeout
>> local nJustify, nFont
>> local oShapes, oCuadro, oFill, oLine, oCuadrotext
>> local oFont := OleGetProperty( ::OleTexto, "Font")
>> local aSal := {.f.,''}, lnocabe := .f.
>>
>>
>> nLen := AT( SP_REG, SubStr( cTextFormat, nPos ) )
>> cFormat := SubStr( cTextFormat, nPos, nLen - 1 )
>> nPos += nLen
>> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) )
>> cVersion := SubStr( cTextFormat, nPos, nLen - 1 )
>> nPos += nLen
>>
>> if !( cFormat == FORMAT_TEXT_TYPE )
>> asal[1] := .f.
>> return asal
>> endif
>>
>> do whil .t.
>>
>> if Substr( cTextFormat, npos, 1 ) == SP_FIELD
>> nPos += 1
>> exit
>> endif
>>
>> cFacename := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
>> nPos ) ) -1 )
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>> cHeight := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
>> nPos ) ) -1 )
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> cWidth := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
>> nPos ) ) -1 )
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> lBold := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> lItalic := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> lUnderline := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> lStrikeOut := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> aadd( afuentes, {cFacename, cHeight, cWidth, lBold, lItalic, lUnderline,
>> lStrikeOut})
>>
>> enddo
>>
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>> oCuadro := OleInvoke( oShapes, "AddTextbox",
>> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
>> oFill := OleGetProperty( oCuadro, "Fill" )
>> OleSetProperty( oFill, "Transparency",0)
>> OleSetProperty( oFill, "Visible",0)
>> oLine := OleGetProperty( oCuadro, "Line" )
>> OleSetProperty( oLine, "Transparency",0)
>> OleSetProperty( oLine, "Visible",0)
>> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
>> oText := OleGetProperty( oCuadroText, "TextRange" )
>> OleInvoke(ocuadro,'Select')
>>
>>
>> do while ( cType := SubStr( cTextFormat, nPos, 1 ) ) != SP_FIELD
>> if cType == TP_ALIGN .or. cType == TP_FONT .or. cType == TP_COLOR
>> if cType == TP_ALIGN
>> njustify := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 ))
>> ::Justificadoc(njustify)
>> endif
>> if cType == TP_FONT
>> nfont := val(SubStr( cTextFormat, nPos + 1, nLen -1 ))
>> OleSetProperty( oFont, "Name", afuentes[nfont,1] )
>> OleSetProperty( oFont, "Size", if( val(afuentes[nfont,2]) < 0,
>> val(afuentes[nfont,2])*-1, val(afuentes[nfont,2]) ) )
>> OleSetProperty( oFont, "Bold", afuentes[nfont,4] )
>> OleSetProperty( oFont, "Italic", afuentes[nfont,5] )
>> OleSetProperty( oFont, "Underline", afuentes[nfont,6] )
>> OleSetProperty( oFont, "StrikeThrough", afuentes[nfont,7] )
>> endif
>> if cType == TP_COLOR
>> ncolortext := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 ))
>> OleSetProperty( oFont,"Color", ncolortext )
>> endif
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>> else
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nCrLf := At( CRLF, SubStr( cTextFormat, nPos ) )
>> if nLen == 0
>> if nCrLf == 0
>> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) ) - 1
>> else
>> nLen := nCrLf + 1
>> endif
>> else
>> if nCrLf == 0 .or. nCrLf > nLen
>> do while SubStr( ctextformat, nPos + --nLen - 1, 1 ) > Chr( 32 )
>> enddo
>> --nLen
>> else
>> nLen := nCRLf + 1
>> endif
>> endif
>> cText = SubStr( cTextFormat, nPos, nLen )
>>
>> lnocabe := OleGetProperty( oCuadroText, 'Overflowing')
>> if lnocabe
>> asal[2] := substr( ctextformat,1, 4 )
>> asal[2] := asal[2] + substr( ctextformat, 5, At( SP_FIELD, Substr(
>> cTextformat, 5) ))
>> asal[2] := asal[2] + substr( ctextformat, nPos + nLen)
>> exit
>> endif
>>
>> cText = SubStr( cTextFormat, nPos, nLen )
>> OleInvoke( ::Oletexto, "Typetext", cText )
>>
>> nPos += nLen
>> endif
>> enddo
>>
>>
>> OleInvoke( oFont,"Reset" )
>> release oShapes, oCuadro, oFill, oLine, oCuadrotext, oFont
>> return asal
>>
>>
>>
>
>
Xevi
Mensajes: 1706
Registrado: Jue Sep 08, 2005 12:58 pm

Word desde Xailer.

Mensaje por Xevi »

Rene,
He intentado añadir esta clase a un proyecto hecho con Xailer...
donde #include "elotroproducto.ch"... "Xailer.ch"
Y lanza una pila de errores al compilar.
He intentado "depurarlo... pero me atasco en alguna parte.
Gracias.
Un Saludo,
Xevi.
"Rene Flores" <"rflores[nospam]"@ciber-tec.com> escribió en el mensaje
news:[email=48ce8795@ozsrv2.ozlan.local...]48ce8795@ozsrv2.ozlan.local...[/email]
> Xevi:
>
> La clase TWord de "el otro producto" funciona perfectamente con Xailer,
> porque todo lo hace via OLE.
>
> Saludos
>
> Rene Flores
> http://www.ciber.tec.com
>
> escribió:
>> Muy buenas...
>>
>> Álguien tiene algun ejemplo de como utilizar Word desde Xailer...
>> Cómo... enviar texto, todo o parte... cambiar texto, combinar
>> correspondencia, imprimir.
>>
>> Gracias.
>>
>> Un Saludo,
>> Xevi.
>>
>>
>
>
------------------------------------------------------------ --------------------
> // Clase TWord
> // Esta clase fue iniciada por Pedro Arribas Lopez
> // Se ha de linkar junto con la clase Ole2 de Jose Gimenez, ya que la
> // clase OLE original de Fivewin produce un error
> //
> // Modificaciones y añadidos:
> // 22-11-2002 Sebastian Almiron - Se ha añadido el Metodo SayRTF() para
> poder
> // imprimir textos FGET. El metodo devuelve un array de dos posiciones, la
> // primera devuelve .t. si el texto cabe dentro del marco especificado y
> .f.
> // si no cabe en el marco o no es un texto FGET. La segunda posición
> contiene
> // una cadena FGET con el texto que no cabe en el marco. De este modo
> podemos
> // decidir que hacer con el resto del texto FGET (Pj.: ponerlo en la
> siguiente
> // pagina.
> // 20-11-2002 Sebastian Almiron - Se ha modificado el metodo AddImagen()
> para
> // que coloque la imagen dentro de un cuadro de texto nuevo, de manera que
> esta
> // se pueda colocar en cualquier parte del documento, ya que como estaba
> originalmente
> // siempre se ponia donde estubiera el cursor.
> // 30-07-2002 Sebastian Almiron - modificado el metodo CMSAY que ahora
> hace
> // una llamada a ::Say despues de recalcular la posicion x e y
> // 7-5-2002 Sebastian Almiron - Se ha incorporado el metodo
> CheckSpelling() que
> // llama al corrector ortografico. Debe tenerse el documento en pantalla.
> Por
> // ejemplo despues de llamar a ::Visualizar().
> // 7-5-2002 Sebastian Almiron - Se han incorporados los metodos ::Gotop y
> // ::GoBottom()
> // 6-5-2002 Sebastian Almiron - Los metodos say, line, etc. ahora pueden
> // referirse a la cabecera o al cuerpo principal del documento
> // Ello nos permitirá crear el "impreso" sobre la cabecera cuando este
> // se repita en muchas hojas, consiguiendo con ello un ahorro
> // considerable de tiempo y espacio. El metodo SetHeader() hace que todos
> // los metodos de pintado/escritura se redirijan a la cabecera y el metodo
> // SetMainDoc() hace que se escriban en el cuerpo principal del documento.
> // 6-5-2002 Sebastian Almiron - El metodo tabpredeterminado(ncmpos) es
> para
> // indicar la distancia de los tabuladoores predeterminados
> // 6-5-2002 Sebastian Almiron - Existe una nueva propiedad ::oLastsay
> // que es el ultimo say mandado al documento, ello nos permitirá darle
> // formato, como por ejemplo añadirle tabuladores.
> // 6-5-2002 Sebastian Almiron - El metodo TabClearAll(ocuadrotext) elimina
> // todos los tabuladores existentes, se le puede pasar de parametro el
> // ultimo say (::olastsay), por defecto se refiere al documento.
> // 6-5-2002 Sebastian Almiron - El metodo AddTabulador(ocuadrotexto) sirve
> // para añadir un tabulador, bien al documento (valor por defecto) o bien
> // al ultimo say (::olastsay)
> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo ::Box(), su uso es
> // similar al mismo metodo de TPrinter
> // 6-5-2002 Sebastian Almiron - Se han añadido los metodos ::SetPortrair()
> y
> // setlandscape() al igual que en TPrinter
> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo
> ::Protect(password) que
> // permite proteger el documento contra cualquier modificacion.
> // 6-5-2002 Sebastian Almiron - Se ha modificado el metodo ::startpage() y
> endpage()
> // que producia bajo ciertas circunstancias paginas en blanco,
> // ahora se aproxima mas a su uso con TPrinter. En realidad Endpage() no
> // hace nada pero lo he dejado por mantener la compatibilidad con TPrinter
> // 6-5-2002 Sebastian Almiron - Se ha motificado el metodo ::Say(), ahora
> se le
> // puede indicar la anchura del cuadro de texto, por defecto calcula la
> anchura
> // para ajustarlo al texto. Se le puede pasar la altura del cuadro con
> ello
> // nos permitirá crear cuadros grandes en el que el texto esté separado
> por
> // tabuladores y retornos de carro, evitando tener que crear tantos
> cuadros
> // de texto.
>
> #include "FiveWin.Ch"
> #define TAB chr(9)
> #define ENTER chr(13)
>
> #define ALI_LEFT 0
> #define ALI_CENTER 1
> #define ALI_RIGHT 2
> #define ALI_JUSTIFY 3
>
> #define LOGPIXELSX 88
> #define LOGPIXELSY 90
>
> // Recorders and fields delimiters of GTF structure
>
> #define SP_REG Chr( 5 )
> #define SP_FIELD Chr( 7 )
>
> #define TP_FONT Chr( 15 )
> #define TP_COLOR Chr( 16 )
> #define TP_ALIGN Chr( 17 )
>
> // Indentify and version of GTF files
>
> #define FORMAT_TEXT_TYPE "GTF"
> #define FORMAT_TEXT_VERSION "1"
>
> // LA CLASE TWORD
>
> CLASS TWord
> DATA OleWord
> DATA hdc INIT 0
> DATA OleDocs
> DATA OleActiveDoc
> DATA OleTexto
> DATA oselection
> DATA cNombreDoc
> DATA nLinea,nCol, nPage
> DATA nYoffset, nXoffset
> DATA lstartpag
> DATA oLastSay
>
> METHOD New()
> METHOD NewDoc( cNombreDoc )
> METHOD OpenDoc( cNombreDoc )
> METHOD Write( cTexto, cFuente, cSize, lBold, lShadow, nColor )
> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLine, nColor, cTexto,
> oFuente, nJustify )
> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
> METHOD FillRect( aRect, oBrush )
> METHOD AddImagen( nTop,nLeft,nBottom,nRight, cImagen )
> //bySebastianAlmiron
> METHOD Visualizar INLINE OleSetProperty( ::OleWord, "Visible", .t. )
> METHOD JustificaDoc( nJustify )
> METHOD Replace( cOld,cNew )
> METHOD Save()
> METHOD StartPage()
> METHOD EndPage()
> METHOD nHorzRes()
> METHOD nHorzSize()
> METHOD nVertRes()
> METHOD nVertSize()
> METHOD nLogPixelX()
> METHOD nLogPixelY()
> METHOD GetTextHeight( cFont, oFont )
> METHOD PrintDoc()
> METHOD Preview()
> METHOD VistaCompleta()
> METHOD End()
> METHOD Protect(cpassword) // bySebastianAlmiron
> METHOD SetLandScape() // bySebastianAlmiron
> METHOD SetPortrait() // bySebastianAlmiron
> METHOD Box(ntop, nleft, nbottom, nright) //bySebastianAlmiron
> METHOD GetTextWidth(cText, oFont)//bySebastianAlmiron
> METHOD addTabulador(ncmpos,ocuadrotext)//bySebastianAlmiron
> METHOD TabClearAll(ocuadrotext)//bySebastianAlmiron
> METHOD TabPredeterminado(ncmpos)//bySebastianAlmiron
> METHOD SetHeader()//bySebastianAlmiron
> METHOD SetMainDoc()//bySebastianAlmiron
> METHOD Gotop() //bySebastianAlmiron
> METHOD GoBottom() //bySebastianAlmiron
> METHOD CheckSpelling() //bySebastianAlmiron
> METHOD SayRTF( ntop, nleft, ctextFormat, nBottom, nright )
> //bySebastianAlmiron
> ENDCLASS
>
> METHOD NEW( cDoc )
> ::OleWord := CreateOleObject( "Word.Application" )
> return Self
>
> METHOD NewDoc( cNombreDoc )
> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
> OleInvoke( ::OleDocs,"Add")
> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
> ::cNombreDoc := cNombreDoc
> ::nLinea := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::lstartpag := .t.
> ::oselection := ::OleActiveDoc
> return nil
>
> METHOD OpenDoc( cNombreDoc )
> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
> IF FILE( cNombreDoc )
> ::OleActiveDoc := OleInvoke( ::OleDocs,"Open",cNombreDoc )
> ELSE
> OleInvoke( ::OleDocs,"Add")
> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
> ENDIF
> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
> ::cNombreDoc := cNombreDoc
> ::nLinea := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::oselection := ::OleactiveDoc
> ::lstartpag := .t.
> return nil
>
> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
> Local oFont := OleGetProperty( ::OleTexto, "Font")
> OleSetProperty( oFont, "Name", oFuente:cFaceName )
> OleSetProperty( oFont, "Size", int(oFuente:nHeight) )
> OleSetProperty( oFont, "Bold", oFuente:lBold )
>
> if ::nLinea < nLin
> OleInvoke( ::OleTexto,"TypeText", chr(13) )
> ::nLinea:= nLin
> ::nCol := 0
> endif
> if ::nCol < nCol
> OleInvoke( ::OleTexto,"TypeText", chr(9) )
> ::nCol:=nCol
> endif
>
>
> OleInvoke( ::OleTexto,"TypeText", cTexto )
> OleInvoke( oFont,"Reset" )
> release oFont
> return nil
>
> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLinea, nColor, cTexto,
> oFuente, nJustify )
> LOCAL oShapes,oCuadro,oFill,oLinea, oFontC, oText, oCuadroText
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop) )
> oFill := OleGetProperty( oCuadro, "Fill" )
> oFillColor := OleGetProperty( oFill,"ForeColor")
> OleSetProperty( oFillColor,"RGB",nColor )
>
> oLinea := OleGetProperty( oCuadro, "Line" )
> if lLinea
> OleSetProperty( oLinea, "Weight", 1 )
> else
> OleSetProperty( oLinea, "Transparency",0)
> OleSetProperty( oLinea, "Visible",0)
> endif
>
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> oFontC := OleGetProperty( oText, "Font")
>
> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
> OleSetProperty( oFontC, "Size", INT(oFuente:nHeight) )
> OleSetProperty( oFontC, "Bold", oFuente:lBold )
> OleSetProperty( oText, "Text", cTexto )
>
> oParagraph := OleGetProperty( oText, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nJustify )
>
> release oParagraph, OLinea, oFillColor, oFill, oFontC, oText,oCuadroText,
> oCuadro
> return nil
>
> METHOD AddImagen( nTop, nLeft, nBottom, nRight, cImagen )
>
> LOCAL oShapes,oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
> oCuadro6, oCuadro7
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
> oLinea := OleGetProperty( oCuadro, "Line" )
> OleSetProperty( oLinea, "Transparency",0)
> OleSetProperty( oLinea, "Visible",0)
>
> oCuadro2 := OleGetProperty(oCuadro,'Anchor')
> oCuadro3 := OleGetProperty(oCuadro2,'ShapeRange')
> oCuadro4 := OleGetProperty(oCuadro3,'TextFrame')
> oCuadro5 := OleGetProperty(oCuadro4,'TextRange')
>
> oCuadro6 := OleGetProperty(oCuadro5,'InlineShapes')
> oCuadro7 := Oleinvoke(oCuadro6, "AddPicture", cImagen,.F.,.T.)
>
> release oShapes, oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
> oCuadro6, oCuadro7
> return nil
>
>
> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
> naltura )
> LOCAL oShapes,oFill,oLine,oCuadroText,oText,oFontC,oParagraph
> local nTamFuente := if(oFuente:nHeight > 0, int(oFuente:nHeight + 2.8),
> int((oFuente:nHeight*-1)+2.8) )
>
> DEFAULT nClrText := nRGB(0,0,0), nBkMode := 2, nPad := 0
> DEFAULT nSizeHorz := ::GetTextWidth(ctexto,oFuente)
> DEFAULT naltura := if(oFuente:nHeight > 0, oFuente:nHeight + 12,
> (oFuente:nHeight*-1)+12)
>
> nSizeHorz := nSizeHorz + (nSizeHorz*25/100)
>
> do case
> case npad = 1
> ncol := ncol - nSizeHorz
> npad := 2
> case npad = 2
> ncol = ncol - (nSizeHorz/2)
> npad := 1
> endcase
> oShapes := OleGetProperty( ::oselection,"Shapes" ) //::OleactiveDoc
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nCol),INT(nLin),nSizeHorz,naltura )
> oFill := OleGetProperty( oCuadro, "Fill" )
> oLine := OleGetProperty( oCuadro, "Line" )
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> oFontC := OleGetProperty( oText, "Font")
> oParagraph := OleGetProperty( oText, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nPad )
> OleSetProperty( oFill, "Transparency",0)
> OleSetProperty( oFill, "Visible",0)
> OleSetProperty( oLine, "Transparency",0)
> OleSetProperty( oLine, "Visible",0)
> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
> OleSetProperty( oFontC, "Size", nTamfuente )
> //INT(oFuente:nHeight*-1) )
> OleSetProperty( oFontC, "Bold", oFuente:lBold )
> OleSetProperty( oFontC, "Italic", oFuente:lItalic )
> OleSetProperty( oText, "Text", cTexto )
>
> OleSetProperty( oCuadroText, "MarginLeft",0)
> OleSetProperty( oCuadroText, "MarginRight",0)
>
> ::oLastSay := otext
>
> release oFontC,oText,oCuadro,oLine,oFill,oShapes,oParagraph,ocuadrot ext
>
> return NIL
>
> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
> naltura )
>
> nCol := Max( 0, ( nCol * 10 * ::nHorzRes() / ::nHorzSize() ) -
> ::nYoffset )
> nLin := Max( 0, ( nLin * 10 * ::nVertRes() / ::nVertSize() ) -
> ::nXoffset )
>
> ::Say(nLin,nCol,ctexto,oFutnte,nZizeHorz,nClrText,nBkMode,nP ad,naltura)
>
> return NIL
>
> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
> LOCAL oShapes,oShapLinea, oLinea
> if oPen = NIL
> DEFINE PEN oPen
> endif
>
> oShapes := OleGetProperty( ::oselection ,"Shapes" )
> oShapLinea := OleInvoke( oShapes, "AddLine", nLeft,nTop,nRight,nBottom )
> oLinea := OleGetProperty( oShapLinea, "Line" )
> OleSetProperty( oLinea, "Weight", oPen:nWidth-2 )
> oPen:End()
> release oLinea,oShapLinea,oShapes
>
> return nil
>
> METHOD FillRect( aRect, oBrush )
> LOCAL oShapes,oShapBox, oFill, oFillColor
> LOCAL nTop := INT(arect[1])
> LOCAL nLeft := INT(arect[2])
> LOCAL nWidth := INT(aRect[4]-aRect[2])
> LOCAL nHeight := INT(aRect[3]-aRect[1])
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oShapBox := OleInvoke( oShapes,
> "AddShape",1,nLeft,nTop,nWidth,nHeight )
> oFill := OleGetproperty( oShapBox,"Fill")
> oFillColor := OleGetProperty( oFill,"ForeColor")
> OleSetProperty( oFillColor,"RGB",oBrush:nRGBColor )
> oBrush:End()
>
> release oFillColor,oFill,oShapBox,oShapes
> return nil
>
> METHOD GetTextHeight( cFont, oFont )
> return oFont:nHeight
>
> METHOD Write( cTexto, cFuente, nSize, lBold, lShadow, nColor )
> Local oFont := OleGetProperty( ::OleTexto, "Font")
> OleSetProperty( oFont, "Name", cFuente )
> OleSetProperty( oFont, "Size", nSize )
> OleSetProperty( oFont, "Bold", lBold )
> OleSetProperty( oFont, "ColorIndex",nColor )
> OleSetProperty( oFont, "Emboss",lShadow )
>
> OleInvoke( ::OleTexto,"TypeText", cTexto )
> OleInvoke( oFont,"Reset" )
> release oFont
> return nil
>
> METHOD Replace( cOld, cNew )
> LOCAL oTexto, oFind, oReplace
>
> oTexto := OleInvoke( ::oselection, "Range" )
> oFind := OleGetProperty( oTexto, "Find" )
>
> OleSetProprerty( oFind, "Text", cOld )
> OleSetProprerty( oFind, "Forward", .T. )
> OleSetProprerty( oFind, "Wrap", INT(1) )
> OleSetProprerty( oFind, "Format", .f. )
> OleSetProprerty( oFind, "MatchCase", .f. )
> OleSetProprerty( oFind, "MatchWholeWord", .f. )
> OleSetProprerty( oFind, "MatchWildcards", .f. )
> OleSetProprerty( oFind, "MatchSoundsLike", .f. )
> OleSetProprerty( oFind, "MatchAllWordForms", .f. )
>
> OleInvoke( oFind, "Execute")
> DO WHILE OleGetProprerty( oFind, "Found" )
> OleSetProprerty( oTexto, "Text", cNew )
> OleInvoke( oFind, "Execute")
> Enddo
>
> release oReplace,oFind,oTexto
> return nil
>
> METHOD JustificaDoc( nJustify )
> LOCAL oParagraph := OleGetProperty( ::Oletexto, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nJustify )
> release oParagraph
> return nil
>
> METHOD Save()
> OleInvoke( ::OleActiveDoc,"SaveAs", ::cNombreDoc )
> return nil
>
> METHOD StartPage()
> if ::lstartpag = .t.
> ::lstartpag := .f.
> else
> OleInvoke(::OleTexto,"EndKey",6,0)
> OleInvoke(::OleTexto,"InsertBreak")
> OleInvoke(::Oletexto,"GotoNext",1)
> ::nPage++
> ::nLinea:=0
> ::nCol :=0
> endif
> return nil
>
> METHOD EndPage()
> return nil
>
> METHOD PrintDoc()
> OleInvoke( ::OleWord, "PrintOut" )
> return nil
>
> METHOD Preview()
> OleSetProperty( ::OleWord, "PrintPreview",.f.)
> OleInvoke( ::OleActiveDoc, "PrintPreview")
> ::Visualizar()
> return nil
>
> METHOD VistaCompleta()
> LOCAL oWindow, oView
>
> oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> oView := OleGetProperty( oWindow , "View" )
> OleSetProperty( oView,"FullScreen", .T. )
> ::Visualizar()
> release oView
> return nil
>
> METHOD nHorzRes()
> nRes := 2
> return nres
>
> METHOD nHorzSize()
> nRes := 1
> return nres
>
> METHOD nVertRes()
> nRes := 2
> return nres
>
> METHOD nVertSize()
> nRes := 1
> return nres
>
> METHOD nLogPixelY()
> LOCAL nPixels := 55.38
> return nPixels
>
> METHOD nLogPixelX()
> LOCAL nPixels := 55.38
> return nPixels
>
> METHOD End()
> OleInvoke(::OleWord,"Quit",0)
> ::OleTexto := NIL
> ::OleActiveDoc := NIL
> ::OleDocs := NIL
> ::Oleword := NIL
> OleUninitialize()
> return nil
>
> METHOD Protect(cpassword)
> OleInvoke( ::OleActiveDoc,"Protect", 2, .F., cpassword )
> return
>
> METHOD SetLandScape()
> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
> OleSetProperty( oPageSetup,'Orientation','1')
> release oPageSetup
> return
>
> METHOD SetPortrait()
> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
> OleSetProperty( oPageSetup,'Orientation','0')
> release oPageSetup
> return
>
> METHOD Box( nTop, nLeft, nBottom, nRight )
> local oShapes,oShapBox
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
>
> nRight := nRight - nLeft
> nBottom := nBottom - nTop
>
> oShapBox := OleInvoke( oShapes,
> "AddShape",1,nLeft,nTop,nRight,nBottom )
>
> release oShapBox,oShapes
> return nil
>
> METHOD GetTextWidth(cText, oFont)
> local nancho
> if oFont:nHeight > 0
> nancho := (oFont:nHeight/1.6)*len(ctext)
> else
> nancho :=((oFont:nHeight*-1)/1.6)*len(ctext)
> endif
> return nancho
>
> METHOD addtabulador(npos, ocuadrotext)
> local otabstop, oParagraphFormat
> DEFAULT ocuadrotext := ::OleTexto
> oParagraphFormat := OleGetProperty(ocuadrotext, 'ParagraphFormat')
> otabstop := OleGetProperty(oParagraphFormat, 'TabStops')
> OleInvoke(otabstop,'Add',npos)
> release oParagraphFormat, otabstop
> return nil
>
> METHOD TabClearAll(ocuadrotext)
> local oparagraphformat, otabstop
> DEFAULT ocuadrotext := ::Oletexto
> oparagraphformat := OleGetProperty(ocuadrotext,'ParagraphFormat')
> otabstop := OleGetProperty(oParagraphformat, 'TabStops')
> OleInvoke(otabstop,'ClearAll')
> release oparagraphformat, otabstop
> return nil
>
> METHOD TabPredeterminado(npos)
> OleSetProperty(::OleactiveDoc,'DefaultTabStop', npos )
> return nil
>
> METHOD SetHeader()
> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> local oView := OleGetProperty( oWindow , "View")
> OleSetProperty(oView,"SeekView",9)
> ::oselection := OleGetProperty( ::OleTexto, "HeaderFooter")
> release oWindow, oView
> return
>
> METHOD SetMainDoc()
> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> local oView := OleGetProperty( oWindow , "View")
> OleSetProperty(oView,"SeekView",0)
> ::oselection := ::OleActiveDoc
> release oWindow, oView
> return
>
> METHOD Gotop()
> OleInvoke(::OleTexto, 'HomeKey', 6)
> return
>
> METHOD GoBottom()
> OleInvoke(::OleTexto, 'EndKey', 6)
> return
>
> METHOD CheckSpelling()
> Oleinvoke(::OleActiveDoc, 'CheckSpelling')
> return
>
> METHOD SayRTF( nTop,nLeft, cTextFormat, nBottom,nRight )
> local cText := "", nPos := 1, nLen := 0, nCrLf, cFormat, cVersion, cType
> local afuentes := {}, nColorText := 0
> local cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeout
> local nJustify, nFont
> local oShapes, oCuadro, oFill, oLine, oCuadrotext
> local oFont := OleGetProperty( ::OleTexto, "Font")
> local aSal := {.f.,''}, lnocabe := .f.
>
>
> nLen := AT( SP_REG, SubStr( cTextFormat, nPos ) )
> cFormat := SubStr( cTextFormat, nPos, nLen - 1 )
> nPos += nLen
> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) )
> cVersion := SubStr( cTextFormat, nPos, nLen - 1 )
> nPos += nLen
>
> if !( cFormat == FORMAT_TEXT_TYPE )
> asal[1] := .f.
> return asal
> endif
>
> do whil .t.
>
> if Substr( cTextFormat, npos, 1 ) == SP_FIELD
> nPos += 1
> exit
> endif
>
> cFacename := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
> cHeight := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> cWidth := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lBold := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lItalic := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lUnderline := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lStrikeOut := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> aadd( afuentes, {cFacename, cHeight, cWidth, lBold, lItalic, lUnderline,
> lStrikeOut})
>
> enddo
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
> oFill := OleGetProperty( oCuadro, "Fill" )
> OleSetProperty( oFill, "Transparency",0)
> OleSetProperty( oFill, "Visible",0)
> oLine := OleGetProperty( oCuadro, "Line" )
> OleSetProperty( oLine, "Transparency",0)
> OleSetProperty( oLine, "Visible",0)
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> OleInvoke(ocuadro,'Select')
>
>
> do while ( cType := SubStr( cTextFormat, nPos, 1 ) ) != SP_FIELD
> if cType == TP_ALIGN .or. cType == TP_FONT .or. cType == TP_COLOR
> if cType == TP_ALIGN
> njustify := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 ))
> ::Justificadoc(njustify)
> endif
> if cType == TP_FONT
> nfont := val(SubStr( cTextFormat, nPos + 1, nLen -1 ))
> OleSetProperty( oFont, "Name", afuentes[nfont,1] )
> OleSetProperty( oFont, "Size", if( val(afuentes[nfont,2]) < 0,
> val(afuentes[nfont,2])*-1, val(afuentes[nfont,2]) ) )
> OleSetProperty( oFont, "Bold", afuentes[nfont,4] )
> OleSetProperty( oFont, "Italic", afuentes[nfont,5] )
> OleSetProperty( oFont, "Underline", afuentes[nfont,6] )
> OleSetProperty( oFont, "StrikeThrough", afuentes[nfont,7] )
> endif
> if cType == TP_COLOR
> ncolortext := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 ))
> OleSetProperty( oFont,"Color", ncolortext )
> endif
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
> else
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nCrLf := At( CRLF, SubStr( cTextFormat, nPos ) )
> if nLen == 0
> if nCrLf == 0
> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) ) - 1
> else
> nLen := nCrLf + 1
> endif
> else
> if nCrLf == 0 .or. nCrLf > nLen
> do while SubStr( ctextformat, nPos + --nLen - 1, 1 ) > Chr( 32 )
> enddo
> --nLen
> else
> nLen := nCRLf + 1
> endif
> endif
> cText = SubStr( cTextFormat, nPos, nLen )
>
> lnocabe := OleGetProperty( oCuadroText, 'Overflowing')
> if lnocabe
> asal[2] := substr( ctextformat,1, 4 )
> asal[2] := asal[2] + substr( ctextformat, 5, At( SP_FIELD, Substr(
> cTextformat, 5) ))
> asal[2] := asal[2] + substr( ctextformat, nPos + nLen)
> exit
> endif
>
> cText = SubStr( cTextFormat, nPos, nLen )
> OleInvoke( ::Oletexto, "Typetext", cText )
>
> nPos += nLen
> endif
> enddo
>
>
> OleInvoke( oFont,"Reset" )
> release oShapes, oCuadro, oFill, oLine, oCuadrotext, oFont
> return asal
>
>
>
Xevi
Mensajes: 1706
Registrado: Jue Sep 08, 2005 12:58 pm

Word desde Xailer.

Mensaje por Xevi »

Rene,
He intentado añadir esta clase a un proyecto hecho con Xailer...
donde #include "elotroproducto.ch"... "Xailer.ch"
Y lanza una pila de errores al compilar.
He intentado "depurarlo... pero me atasco en alguna parte.
Gracias.
Un Saludo,
Xevi.
"Rene Flores" <"rflores[nospam]"@ciber-tec.com> escribió en el mensaje
news:[email=48ce8795@ozsrv2.ozlan.local...]48ce8795@ozsrv2.ozlan.local...[/email]
> Xevi:
>
> La clase TWord de "el otro producto" funciona perfectamente con Xailer,
> porque todo lo hace via OLE.
>
> Saludos
>
> Rene Flores
> http://www.ciber.tec.com
>
> escribió:
>> Muy buenas...
>>
>> Álguien tiene algun ejemplo de como utilizar Word desde Xailer...
>> Cómo... enviar texto, todo o parte... cambiar texto, combinar
>> correspondencia, imprimir.
>>
>> Gracias.
>>
>> Un Saludo,
>> Xevi.
>>
>>
>
>
------------------------------------------------------------ --------------------
> // Clase TWord
> // Esta clase fue iniciada por Pedro Arribas Lopez
> // Se ha de linkar junto con la clase Ole2 de Jose Gimenez, ya que la
> // clase OLE original de Fivewin produce un error
> //
> // Modificaciones y añadidos:
> // 22-11-2002 Sebastian Almiron - Se ha añadido el Metodo SayRTF() para
> poder
> // imprimir textos FGET. El metodo devuelve un array de dos posiciones, la
> // primera devuelve .t. si el texto cabe dentro del marco especificado y
> .f.
> // si no cabe en el marco o no es un texto FGET. La segunda posición
> contiene
> // una cadena FGET con el texto que no cabe en el marco. De este modo
> podemos
> // decidir que hacer con el resto del texto FGET (Pj.: ponerlo en la
> siguiente
> // pagina.
> // 20-11-2002 Sebastian Almiron - Se ha modificado el metodo AddImagen()
> para
> // que coloque la imagen dentro de un cuadro de texto nuevo, de manera que
> esta
> // se pueda colocar en cualquier parte del documento, ya que como estaba
> originalmente
> // siempre se ponia donde estubiera el cursor.
> // 30-07-2002 Sebastian Almiron - modificado el metodo CMSAY que ahora
> hace
> // una llamada a ::Say despues de recalcular la posicion x e y
> // 7-5-2002 Sebastian Almiron - Se ha incorporado el metodo
> CheckSpelling() que
> // llama al corrector ortografico. Debe tenerse el documento en pantalla.
> Por
> // ejemplo despues de llamar a ::Visualizar().
> // 7-5-2002 Sebastian Almiron - Se han incorporados los metodos ::Gotop y
> // ::GoBottom()
> // 6-5-2002 Sebastian Almiron - Los metodos say, line, etc. ahora pueden
> // referirse a la cabecera o al cuerpo principal del documento
> // Ello nos permitirá crear el "impreso" sobre la cabecera cuando este
> // se repita en muchas hojas, consiguiendo con ello un ahorro
> // considerable de tiempo y espacio. El metodo SetHeader() hace que todos
> // los metodos de pintado/escritura se redirijan a la cabecera y el metodo
> // SetMainDoc() hace que se escriban en el cuerpo principal del documento.
> // 6-5-2002 Sebastian Almiron - El metodo tabpredeterminado(ncmpos) es
> para
> // indicar la distancia de los tabuladoores predeterminados
> // 6-5-2002 Sebastian Almiron - Existe una nueva propiedad ::oLastsay
> // que es el ultimo say mandado al documento, ello nos permitirá darle
> // formato, como por ejemplo añadirle tabuladores.
> // 6-5-2002 Sebastian Almiron - El metodo TabClearAll(ocuadrotext) elimina
> // todos los tabuladores existentes, se le puede pasar de parametro el
> // ultimo say (::olastsay), por defecto se refiere al documento.
> // 6-5-2002 Sebastian Almiron - El metodo AddTabulador(ocuadrotexto) sirve
> // para añadir un tabulador, bien al documento (valor por defecto) o bien
> // al ultimo say (::olastsay)
> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo ::Box(), su uso es
> // similar al mismo metodo de TPrinter
> // 6-5-2002 Sebastian Almiron - Se han añadido los metodos ::SetPortrair()
> y
> // setlandscape() al igual que en TPrinter
> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo
> ::Protect(password) que
> // permite proteger el documento contra cualquier modificacion.
> // 6-5-2002 Sebastian Almiron - Se ha modificado el metodo ::startpage() y
> endpage()
> // que producia bajo ciertas circunstancias paginas en blanco,
> // ahora se aproxima mas a su uso con TPrinter. En realidad Endpage() no
> // hace nada pero lo he dejado por mantener la compatibilidad con TPrinter
> // 6-5-2002 Sebastian Almiron - Se ha motificado el metodo ::Say(), ahora
> se le
> // puede indicar la anchura del cuadro de texto, por defecto calcula la
> anchura
> // para ajustarlo al texto. Se le puede pasar la altura del cuadro con
> ello
> // nos permitirá crear cuadros grandes en el que el texto esté separado
> por
> // tabuladores y retornos de carro, evitando tener que crear tantos
> cuadros
> // de texto.
>
> #include "FiveWin.Ch"
> #define TAB chr(9)
> #define ENTER chr(13)
>
> #define ALI_LEFT 0
> #define ALI_CENTER 1
> #define ALI_RIGHT 2
> #define ALI_JUSTIFY 3
>
> #define LOGPIXELSX 88
> #define LOGPIXELSY 90
>
> // Recorders and fields delimiters of GTF structure
>
> #define SP_REG Chr( 5 )
> #define SP_FIELD Chr( 7 )
>
> #define TP_FONT Chr( 15 )
> #define TP_COLOR Chr( 16 )
> #define TP_ALIGN Chr( 17 )
>
> // Indentify and version of GTF files
>
> #define FORMAT_TEXT_TYPE "GTF"
> #define FORMAT_TEXT_VERSION "1"
>
> // LA CLASE TWORD
>
> CLASS TWord
> DATA OleWord
> DATA hdc INIT 0
> DATA OleDocs
> DATA OleActiveDoc
> DATA OleTexto
> DATA oselection
> DATA cNombreDoc
> DATA nLinea,nCol, nPage
> DATA nYoffset, nXoffset
> DATA lstartpag
> DATA oLastSay
>
> METHOD New()
> METHOD NewDoc( cNombreDoc )
> METHOD OpenDoc( cNombreDoc )
> METHOD Write( cTexto, cFuente, cSize, lBold, lShadow, nColor )
> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLine, nColor, cTexto,
> oFuente, nJustify )
> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
> METHOD FillRect( aRect, oBrush )
> METHOD AddImagen( nTop,nLeft,nBottom,nRight, cImagen )
> //bySebastianAlmiron
> METHOD Visualizar INLINE OleSetProperty( ::OleWord, "Visible", .t. )
> METHOD JustificaDoc( nJustify )
> METHOD Replace( cOld,cNew )
> METHOD Save()
> METHOD StartPage()
> METHOD EndPage()
> METHOD nHorzRes()
> METHOD nHorzSize()
> METHOD nVertRes()
> METHOD nVertSize()
> METHOD nLogPixelX()
> METHOD nLogPixelY()
> METHOD GetTextHeight( cFont, oFont )
> METHOD PrintDoc()
> METHOD Preview()
> METHOD VistaCompleta()
> METHOD End()
> METHOD Protect(cpassword) // bySebastianAlmiron
> METHOD SetLandScape() // bySebastianAlmiron
> METHOD SetPortrait() // bySebastianAlmiron
> METHOD Box(ntop, nleft, nbottom, nright) //bySebastianAlmiron
> METHOD GetTextWidth(cText, oFont)//bySebastianAlmiron
> METHOD addTabulador(ncmpos,ocuadrotext)//bySebastianAlmiron
> METHOD TabClearAll(ocuadrotext)//bySebastianAlmiron
> METHOD TabPredeterminado(ncmpos)//bySebastianAlmiron
> METHOD SetHeader()//bySebastianAlmiron
> METHOD SetMainDoc()//bySebastianAlmiron
> METHOD Gotop() //bySebastianAlmiron
> METHOD GoBottom() //bySebastianAlmiron
> METHOD CheckSpelling() //bySebastianAlmiron
> METHOD SayRTF( ntop, nleft, ctextFormat, nBottom, nright )
> //bySebastianAlmiron
> ENDCLASS
>
> METHOD NEW( cDoc )
> ::OleWord := CreateOleObject( "Word.Application" )
> return Self
>
> METHOD NewDoc( cNombreDoc )
> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
> OleInvoke( ::OleDocs,"Add")
> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
> ::cNombreDoc := cNombreDoc
> ::nLinea := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::lstartpag := .t.
> ::oselection := ::OleActiveDoc
> return nil
>
> METHOD OpenDoc( cNombreDoc )
> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
> IF FILE( cNombreDoc )
> ::OleActiveDoc := OleInvoke( ::OleDocs,"Open",cNombreDoc )
> ELSE
> OleInvoke( ::OleDocs,"Add")
> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
> ENDIF
> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
> ::cNombreDoc := cNombreDoc
> ::nLinea := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::oselection := ::OleactiveDoc
> ::lstartpag := .t.
> return nil
>
> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
> Local oFont := OleGetProperty( ::OleTexto, "Font")
> OleSetProperty( oFont, "Name", oFuente:cFaceName )
> OleSetProperty( oFont, "Size", int(oFuente:nHeight) )
> OleSetProperty( oFont, "Bold", oFuente:lBold )
>
> if ::nLinea < nLin
> OleInvoke( ::OleTexto,"TypeText", chr(13) )
> ::nLinea:= nLin
> ::nCol := 0
> endif
> if ::nCol < nCol
> OleInvoke( ::OleTexto,"TypeText", chr(9) )
> ::nCol:=nCol
> endif
>
>
> OleInvoke( ::OleTexto,"TypeText", cTexto )
> OleInvoke( oFont,"Reset" )
> release oFont
> return nil
>
> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLinea, nColor, cTexto,
> oFuente, nJustify )
> LOCAL oShapes,oCuadro,oFill,oLinea, oFontC, oText, oCuadroText
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop) )
> oFill := OleGetProperty( oCuadro, "Fill" )
> oFillColor := OleGetProperty( oFill,"ForeColor")
> OleSetProperty( oFillColor,"RGB",nColor )
>
> oLinea := OleGetProperty( oCuadro, "Line" )
> if lLinea
> OleSetProperty( oLinea, "Weight", 1 )
> else
> OleSetProperty( oLinea, "Transparency",0)
> OleSetProperty( oLinea, "Visible",0)
> endif
>
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> oFontC := OleGetProperty( oText, "Font")
>
> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
> OleSetProperty( oFontC, "Size", INT(oFuente:nHeight) )
> OleSetProperty( oFontC, "Bold", oFuente:lBold )
> OleSetProperty( oText, "Text", cTexto )
>
> oParagraph := OleGetProperty( oText, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nJustify )
>
> release oParagraph, OLinea, oFillColor, oFill, oFontC, oText,oCuadroText,
> oCuadro
> return nil
>
> METHOD AddImagen( nTop, nLeft, nBottom, nRight, cImagen )
>
> LOCAL oShapes,oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
> oCuadro6, oCuadro7
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
> oLinea := OleGetProperty( oCuadro, "Line" )
> OleSetProperty( oLinea, "Transparency",0)
> OleSetProperty( oLinea, "Visible",0)
>
> oCuadro2 := OleGetProperty(oCuadro,'Anchor')
> oCuadro3 := OleGetProperty(oCuadro2,'ShapeRange')
> oCuadro4 := OleGetProperty(oCuadro3,'TextFrame')
> oCuadro5 := OleGetProperty(oCuadro4,'TextRange')
>
> oCuadro6 := OleGetProperty(oCuadro5,'InlineShapes')
> oCuadro7 := Oleinvoke(oCuadro6, "AddPicture", cImagen,.F.,.T.)
>
> release oShapes, oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
> oCuadro6, oCuadro7
> return nil
>
>
> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
> naltura )
> LOCAL oShapes,oFill,oLine,oCuadroText,oText,oFontC,oParagraph
> local nTamFuente := if(oFuente:nHeight > 0, int(oFuente:nHeight + 2.8),
> int((oFuente:nHeight*-1)+2.8) )
>
> DEFAULT nClrText := nRGB(0,0,0), nBkMode := 2, nPad := 0
> DEFAULT nSizeHorz := ::GetTextWidth(ctexto,oFuente)
> DEFAULT naltura := if(oFuente:nHeight > 0, oFuente:nHeight + 12,
> (oFuente:nHeight*-1)+12)
>
> nSizeHorz := nSizeHorz + (nSizeHorz*25/100)
>
> do case
> case npad = 1
> ncol := ncol - nSizeHorz
> npad := 2
> case npad = 2
> ncol = ncol - (nSizeHorz/2)
> npad := 1
> endcase
> oShapes := OleGetProperty( ::oselection,"Shapes" ) //::OleactiveDoc
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nCol),INT(nLin),nSizeHorz,naltura )
> oFill := OleGetProperty( oCuadro, "Fill" )
> oLine := OleGetProperty( oCuadro, "Line" )
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> oFontC := OleGetProperty( oText, "Font")
> oParagraph := OleGetProperty( oText, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nPad )
> OleSetProperty( oFill, "Transparency",0)
> OleSetProperty( oFill, "Visible",0)
> OleSetProperty( oLine, "Transparency",0)
> OleSetProperty( oLine, "Visible",0)
> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
> OleSetProperty( oFontC, "Size", nTamfuente )
> //INT(oFuente:nHeight*-1) )
> OleSetProperty( oFontC, "Bold", oFuente:lBold )
> OleSetProperty( oFontC, "Italic", oFuente:lItalic )
> OleSetProperty( oText, "Text", cTexto )
>
> OleSetProperty( oCuadroText, "MarginLeft",0)
> OleSetProperty( oCuadroText, "MarginRight",0)
>
> ::oLastSay := otext
>
> release oFontC,oText,oCuadro,oLine,oFill,oShapes,oParagraph,ocuadrot ext
>
> return NIL
>
> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
> naltura )
>
> nCol := Max( 0, ( nCol * 10 * ::nHorzRes() / ::nHorzSize() ) -
> ::nYoffset )
> nLin := Max( 0, ( nLin * 10 * ::nVertRes() / ::nVertSize() ) -
> ::nXoffset )
>
> ::Say(nLin,nCol,ctexto,oFutnte,nZizeHorz,nClrText,nBkMode,nP ad,naltura)
>
> return NIL
>
> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
> LOCAL oShapes,oShapLinea, oLinea
> if oPen = NIL
> DEFINE PEN oPen
> endif
>
> oShapes := OleGetProperty( ::oselection ,"Shapes" )
> oShapLinea := OleInvoke( oShapes, "AddLine", nLeft,nTop,nRight,nBottom )
> oLinea := OleGetProperty( oShapLinea, "Line" )
> OleSetProperty( oLinea, "Weight", oPen:nWidth-2 )
> oPen:End()
> release oLinea,oShapLinea,oShapes
>
> return nil
>
> METHOD FillRect( aRect, oBrush )
> LOCAL oShapes,oShapBox, oFill, oFillColor
> LOCAL nTop := INT(arect[1])
> LOCAL nLeft := INT(arect[2])
> LOCAL nWidth := INT(aRect[4]-aRect[2])
> LOCAL nHeight := INT(aRect[3]-aRect[1])
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oShapBox := OleInvoke( oShapes,
> "AddShape",1,nLeft,nTop,nWidth,nHeight )
> oFill := OleGetproperty( oShapBox,"Fill")
> oFillColor := OleGetProperty( oFill,"ForeColor")
> OleSetProperty( oFillColor,"RGB",oBrush:nRGBColor )
> oBrush:End()
>
> release oFillColor,oFill,oShapBox,oShapes
> return nil
>
> METHOD GetTextHeight( cFont, oFont )
> return oFont:nHeight
>
> METHOD Write( cTexto, cFuente, nSize, lBold, lShadow, nColor )
> Local oFont := OleGetProperty( ::OleTexto, "Font")
> OleSetProperty( oFont, "Name", cFuente )
> OleSetProperty( oFont, "Size", nSize )
> OleSetProperty( oFont, "Bold", lBold )
> OleSetProperty( oFont, "ColorIndex",nColor )
> OleSetProperty( oFont, "Emboss",lShadow )
>
> OleInvoke( ::OleTexto,"TypeText", cTexto )
> OleInvoke( oFont,"Reset" )
> release oFont
> return nil
>
> METHOD Replace( cOld, cNew )
> LOCAL oTexto, oFind, oReplace
>
> oTexto := OleInvoke( ::oselection, "Range" )
> oFind := OleGetProperty( oTexto, "Find" )
>
> OleSetProprerty( oFind, "Text", cOld )
> OleSetProprerty( oFind, "Forward", .T. )
> OleSetProprerty( oFind, "Wrap", INT(1) )
> OleSetProprerty( oFind, "Format", .f. )
> OleSetProprerty( oFind, "MatchCase", .f. )
> OleSetProprerty( oFind, "MatchWholeWord", .f. )
> OleSetProprerty( oFind, "MatchWildcards", .f. )
> OleSetProprerty( oFind, "MatchSoundsLike", .f. )
> OleSetProprerty( oFind, "MatchAllWordForms", .f. )
>
> OleInvoke( oFind, "Execute")
> DO WHILE OleGetProprerty( oFind, "Found" )
> OleSetProprerty( oTexto, "Text", cNew )
> OleInvoke( oFind, "Execute")
> Enddo
>
> release oReplace,oFind,oTexto
> return nil
>
> METHOD JustificaDoc( nJustify )
> LOCAL oParagraph := OleGetProperty( ::Oletexto, "ParagraphFormat")
> OleSetProperty( oParagraph, "Alignment", nJustify )
> release oParagraph
> return nil
>
> METHOD Save()
> OleInvoke( ::OleActiveDoc,"SaveAs", ::cNombreDoc )
> return nil
>
> METHOD StartPage()
> if ::lstartpag = .t.
> ::lstartpag := .f.
> else
> OleInvoke(::OleTexto,"EndKey",6,0)
> OleInvoke(::OleTexto,"InsertBreak")
> OleInvoke(::Oletexto,"GotoNext",1)
> ::nPage++
> ::nLinea:=0
> ::nCol :=0
> endif
> return nil
>
> METHOD EndPage()
> return nil
>
> METHOD PrintDoc()
> OleInvoke( ::OleWord, "PrintOut" )
> return nil
>
> METHOD Preview()
> OleSetProperty( ::OleWord, "PrintPreview",.f.)
> OleInvoke( ::OleActiveDoc, "PrintPreview")
> ::Visualizar()
> return nil
>
> METHOD VistaCompleta()
> LOCAL oWindow, oView
>
> oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> oView := OleGetProperty( oWindow , "View" )
> OleSetProperty( oView,"FullScreen", .T. )
> ::Visualizar()
> release oView
> return nil
>
> METHOD nHorzRes()
> nRes := 2
> return nres
>
> METHOD nHorzSize()
> nRes := 1
> return nres
>
> METHOD nVertRes()
> nRes := 2
> return nres
>
> METHOD nVertSize()
> nRes := 1
> return nres
>
> METHOD nLogPixelY()
> LOCAL nPixels := 55.38
> return nPixels
>
> METHOD nLogPixelX()
> LOCAL nPixels := 55.38
> return nPixels
>
> METHOD End()
> OleInvoke(::OleWord,"Quit",0)
> ::OleTexto := NIL
> ::OleActiveDoc := NIL
> ::OleDocs := NIL
> ::Oleword := NIL
> OleUninitialize()
> return nil
>
> METHOD Protect(cpassword)
> OleInvoke( ::OleActiveDoc,"Protect", 2, .F., cpassword )
> return
>
> METHOD SetLandScape()
> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
> OleSetProperty( oPageSetup,'Orientation','1')
> release oPageSetup
> return
>
> METHOD SetPortrait()
> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
> OleSetProperty( oPageSetup,'Orientation','0')
> release oPageSetup
> return
>
> METHOD Box( nTop, nLeft, nBottom, nRight )
> local oShapes,oShapBox
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
>
> nRight := nRight - nLeft
> nBottom := nBottom - nTop
>
> oShapBox := OleInvoke( oShapes,
> "AddShape",1,nLeft,nTop,nRight,nBottom )
>
> release oShapBox,oShapes
> return nil
>
> METHOD GetTextWidth(cText, oFont)
> local nancho
> if oFont:nHeight > 0
> nancho := (oFont:nHeight/1.6)*len(ctext)
> else
> nancho :=((oFont:nHeight*-1)/1.6)*len(ctext)
> endif
> return nancho
>
> METHOD addtabulador(npos, ocuadrotext)
> local otabstop, oParagraphFormat
> DEFAULT ocuadrotext := ::OleTexto
> oParagraphFormat := OleGetProperty(ocuadrotext, 'ParagraphFormat')
> otabstop := OleGetProperty(oParagraphFormat, 'TabStops')
> OleInvoke(otabstop,'Add',npos)
> release oParagraphFormat, otabstop
> return nil
>
> METHOD TabClearAll(ocuadrotext)
> local oparagraphformat, otabstop
> DEFAULT ocuadrotext := ::Oletexto
> oparagraphformat := OleGetProperty(ocuadrotext,'ParagraphFormat')
> otabstop := OleGetProperty(oParagraphformat, 'TabStops')
> OleInvoke(otabstop,'ClearAll')
> release oparagraphformat, otabstop
> return nil
>
> METHOD TabPredeterminado(npos)
> OleSetProperty(::OleactiveDoc,'DefaultTabStop', npos )
> return nil
>
> METHOD SetHeader()
> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> local oView := OleGetProperty( oWindow , "View")
> OleSetProperty(oView,"SeekView",9)
> ::oselection := OleGetProperty( ::OleTexto, "HeaderFooter")
> release oWindow, oView
> return
>
> METHOD SetMainDoc()
> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
> local oView := OleGetProperty( oWindow , "View")
> OleSetProperty(oView,"SeekView",0)
> ::oselection := ::OleActiveDoc
> release oWindow, oView
> return
>
> METHOD Gotop()
> OleInvoke(::OleTexto, 'HomeKey', 6)
> return
>
> METHOD GoBottom()
> OleInvoke(::OleTexto, 'EndKey', 6)
> return
>
> METHOD CheckSpelling()
> Oleinvoke(::OleActiveDoc, 'CheckSpelling')
> return
>
> METHOD SayRTF( nTop,nLeft, cTextFormat, nBottom,nRight )
> local cText := "", nPos := 1, nLen := 0, nCrLf, cFormat, cVersion, cType
> local afuentes := {}, nColorText := 0
> local cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeout
> local nJustify, nFont
> local oShapes, oCuadro, oFill, oLine, oCuadrotext
> local oFont := OleGetProperty( ::OleTexto, "Font")
> local aSal := {.f.,''}, lnocabe := .f.
>
>
> nLen := AT( SP_REG, SubStr( cTextFormat, nPos ) )
> cFormat := SubStr( cTextFormat, nPos, nLen - 1 )
> nPos += nLen
> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) )
> cVersion := SubStr( cTextFormat, nPos, nLen - 1 )
> nPos += nLen
>
> if !( cFormat == FORMAT_TEXT_TYPE )
> asal[1] := .f.
> return asal
> endif
>
> do whil .t.
>
> if Substr( cTextFormat, npos, 1 ) == SP_FIELD
> nPos += 1
> exit
> endif
>
> cFacename := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
> cHeight := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> cWidth := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
> nPos ) ) -1 )
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lBold := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lItalic := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lUnderline := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> lStrikeOut := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
>
> aadd( afuentes, {cFacename, cHeight, cWidth, lBold, lItalic, lUnderline,
> lStrikeOut})
>
> enddo
>
> oShapes := OleGetProperty( ::oselection,"Shapes" )
> oCuadro := OleInvoke( oShapes, "AddTextbox",
> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
> oFill := OleGetProperty( oCuadro, "Fill" )
> OleSetProperty( oFill, "Transparency",0)
> OleSetProperty( oFill, "Visible",0)
> oLine := OleGetProperty( oCuadro, "Line" )
> OleSetProperty( oLine, "Transparency",0)
> OleSetProperty( oLine, "Visible",0)
> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
> oText := OleGetProperty( oCuadroText, "TextRange" )
> OleInvoke(ocuadro,'Select')
>
>
> do while ( cType := SubStr( cTextFormat, nPos, 1 ) ) != SP_FIELD
> if cType == TP_ALIGN .or. cType == TP_FONT .or. cType == TP_COLOR
> if cType == TP_ALIGN
> njustify := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 ))
> ::Justificadoc(njustify)
> endif
> if cType == TP_FONT
> nfont := val(SubStr( cTextFormat, nPos + 1, nLen -1 ))
> OleSetProperty( oFont, "Name", afuentes[nfont,1] )
> OleSetProperty( oFont, "Size", if( val(afuentes[nfont,2]) < 0,
> val(afuentes[nfont,2])*-1, val(afuentes[nfont,2]) ) )
> OleSetProperty( oFont, "Bold", afuentes[nfont,4] )
> OleSetProperty( oFont, "Italic", afuentes[nfont,5] )
> OleSetProperty( oFont, "Underline", afuentes[nfont,6] )
> OleSetProperty( oFont, "StrikeThrough", afuentes[nfont,7] )
> endif
> if cType == TP_COLOR
> ncolortext := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
> cTextFormat, nPos ) ) -1 ))
> OleSetProperty( oFont,"Color", ncolortext )
> endif
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nPos += nLen
> else
> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
> nCrLf := At( CRLF, SubStr( cTextFormat, nPos ) )
> if nLen == 0
> if nCrLf == 0
> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) ) - 1
> else
> nLen := nCrLf + 1
> endif
> else
> if nCrLf == 0 .or. nCrLf > nLen
> do while SubStr( ctextformat, nPos + --nLen - 1, 1 ) > Chr( 32 )
> enddo
> --nLen
> else
> nLen := nCRLf + 1
> endif
> endif
> cText = SubStr( cTextFormat, nPos, nLen )
>
> lnocabe := OleGetProperty( oCuadroText, 'Overflowing')
> if lnocabe
> asal[2] := substr( ctextformat,1, 4 )
> asal[2] := asal[2] + substr( ctextformat, 5, At( SP_FIELD, Substr(
> cTextformat, 5) ))
> asal[2] := asal[2] + substr( ctextformat, nPos + nLen)
> exit
> endif
>
> cText = SubStr( cTextFormat, nPos, nLen )
> OleInvoke( ::Oletexto, "Typetext", cText )
>
> nPos += nLen
> endif
> enddo
>
>
> OleInvoke( oFont,"Reset" )
> release oShapes, oCuadro, oFill, oLine, oCuadrotext, oFont
> return asal
>
>
>
Avatar de Usuario
gerencia
Mensajes: 282
Registrado: Sab Jun 20, 2009 6:01 pm

Word desde Xailer.

Mensaje por gerencia »

This is a multi-part message in MIME format.
--------------010302090201080702030603
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000066">
Xevi,<br>
<br>
Esta es la que uso con Xailer no se si es la misma, mira a ver si te
sirve.<br>
<br>
<br>
-- <br>
<div class="moz-signature">
<meta http-equiv="CONTENT-TYPE" content="text/html; ">
<title>Josà David Angulo</title>
<meta name="GENERATOR" content="OpenOffice.org 2.0 (Win32)">
<meta name="CREATED" content="20061023;14550935">
<meta name="CHANGEDBY" content="Jose Angulo">
<meta name="CHANGED" content="20061023;14593800">
<meta name="ProgId" content="Word.Document">
<meta name="Originator" content="Microsoft Word 9">
<style>
<!--
P { color: #000000 }
-->
</style>
<p style="margin-bottom: 0cm;"><font size="2"><span
style="background: transparent none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b><font
face="Century Gothic"><font color="#000080">JosÃ
David Angulo.</font></font></b></span><font face="Arial"><font
color="#0000ff"><br>
</font></font></font><font face="Arial"><font color="#0000ff"><b><font
style="font-size: 11pt;" size="2">A<span lang="en-GB">uditorÃa
y Sistemas Ltda. </span></font></b><br>
<font style="font-size: 8pt;" size="1">Tel.</font></font></font><font
size="1"><font face="Century Gothic"><font color="#808080">(57)
5- 6643022 – 6644555</font></font></font></p>
<p style="margin-bottom: 0cm;"><font size="1"><font
face="Century Gothic"><font color="#808080">Cartagena - Colombia</font></font></font><br>
<a href="mailto:Gerencia@microexpressltda.com"><font
style="font-size: 9pt;" size="2">jose.angulo@auditoriaysistemas.com</font></a></p>
<p style="margin-bottom: 0cm;"><br>
</p>
</div>
<br>
<br>
<br>
Xevi escribiÃ:
<blockquote cite="mid:48d113f0@ozsrv2.ozlan.local" type="cite">
<pre wrap="">Rene,
He intentado aÃadir esta clase a un proyecto hecho con Xailer...
donde #include "elotroproducto.ch"... "Xailer.ch"
Y lanza una pila de errores al compilar.
He intentado "depurarlo... pero me atasco en alguna parte.
Gracias.
Un Saludo,
Xevi.
</pre>
</blockquote>
<br>
</body>
</html>
--------------010302090201080702030603
Content-Type: application/x-zip-compressed;
name="TwordX.zip"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="TwordX.zip"
UEsDBBQAAgAIADZ7HTfVdusYXR8AAMOQAAAKAAAAVHdvcmRYLnByZ9097XLb OJL/p2reAavd
KkkxLVt2kkl046lVbDnxrmL5bOVjbja1RVN0zA1N6kgqiWdqHnYfYH/tC1x3 44MACJKS8zG3
46pEEtFoNIBGo7vRaO7c+/Ybxv50shix+Yc0WwyW2VvvPRsOhmxvd/f+zu7+ zvAxGz4cPXg8
uv8dex8FRZqxyccl+9O332DVw9jPQzZ/BXXx53iF5SN2EV76eRH9M2Hj+CbK /p1w6OfpIrqK
An/hsyXBvfwXIXzuJ6swZvP05p85O/qX/zP7ibGX0bviGgrZG2iXvv45yML8 Q5QMgvQG0bFn
IfvfVVT4i5QV6cLPWYz/Yv/Gxx8+/bxaJUGUJmHOZnH4NCzOsnQZZsVtr888 fHRRfXSSvE/f
hb3+gBoZQ8s+g/qrHAmPfRbwTgMk9hdq3bJ8lbPnIRCR5mwErQCi0QX/4Nj4 ALCtLfZ8Mn82
O4IhShY3fhT3WDwuCj+4Zn0L4lnoL8LsOE2LMOuxZLYsoB8cqgSaLcPkyC/8 i3SVBWGPBcdR
HNpA48XiOArjBRXDp13+Krw889+GZ1n4Pgo/9PqcWOSAwe7+YPexJAwbYunc v4zD3CIWmuDP
sfa9nW+/+WOUBPFqEbLOa+hlmA2C6w7i3dn54yK8ipKQsfn4CeAIrrPeY6ik Hk9O55Nzejzc
J1JUyXh68vfp5HgOtdiu9fyQV2ND6/n5ydNnWGHPev6XFxfzk+Mf2b5F1HT2 9Ozk9WR68Zqx
R4/cRT8y9niX12Pn4dsoLzKY91u2COPohvgRGBV+scC/Wab0LUYWKrJVUKyA m57Oj0tyLs7+
fj55in06hD6zB6xvlB2fTKZHouw7vWwOZbPTuSgaPrDKDmfT2bksfGgVwgg8 PZWFhJU6c7II
k4IvUVh5t+x9mOXRvxPeAVhLUXAdYlcN+o9n58/H87/PJ6/hvx/PJoz/dQCo 44Z6OTm/OJmd
Crih4As2HbPD6fhiAvJkdn6ED/HnRSle8O9oPB+ztPrkKA1y88k4KKL3ITw3 H8/Dj0VqProI
4zDA1WU8Dk7Tm8usgiCZQnd8LzlMY48luG7M4h/Tq6s8LKDsNf9mFMd54WfF 0n9rUjAFcXnh
35qgMxj+qzgFiWdCJzAXwHEfTGqxX7KGiQcE0eGNEECqRS5Oclb+wQzMLv8B QoxVy8TfT0oq
vzGxPYc1/jzM3oY6tkMYvyjxMxakGSyIZZoAewWR34qtFGhV2lRLNlAjNhJ7 eQs2HagWm4mp
BpsNVIuNy0w3tmqZC5vEV8rhkxvgyQR2jHm6BC6chlfIjE/Sokhv4Mt59PYa HgQczGN+TPzM
YOEvU/jIUtiN1E6jofYXi8K/XMUoG3oJyDWPpcHKX0AFYD0b+kn6sY0E/wo4 InVTgAzowWqJ
bpZyP9OQB3Gahz376eENLKEeLVC+PGlNpF56vAKxFnrJRfRz+CzNfobSOMMy L3nyDpQSKDrz
F9CyH6N4hi9QO81OgF8/AhEvQTkYL/6xyosKIYfXYfDuYhnG0IW3FYImycL1 DGVG5Tns2/E5
SKEe8/EDxvZJtsqvKy2CcoGUPwtxDHvAj2lSJUsAvYoWxXWPRsHjkBXAlE8K KDEnp9OT0wkb
jbiEFHpLj3WB4r+Gt12PPazWhvltqvosvQlr6v4FhpN2GpCvMGf85y2QicxU 6RDK3DZ2Ss+Q
nfnUwedFcevgnFOu39jPiIhS4FeqJdP07Vn0MYxfl9198GCw/6gO7sdmOFLb WtrU1DHreZQU
WDm+9IN3b7N0lQDvxv4ScCITn/vJ2xAW+GxVLFcF6oPw8CqjoSpwfUVFiN+D dBn5sIgD2I3C
vNoKzASwI5TmOdoGXnID6q0Ndh4uY58Uz1kMjQcwlpWOXPjvw16QUEcXaVAt /hKLFnZCUMSc
ixYa3GtokVGTgOJJil2KL65B4n2Q+F3YQNMRzCl4kzAep9mNrzEq59Nqfdyd K5MMT7n+7yqZ
+sniIvCXVSkChbAJEWs5is7SrMj8qHCVvYirT1FVcQor2JoO49DPxnHca9gD AAyYeBGCAXMD
isAi7SVo/FXAoOoa24WYJlbOUxBnBck2ZI0nsBg8TZDYu4vGEQCWZhEgoY3O JudFUuF9G+Ql
qPw+qDewNxV+ZXSgdAWt/gyaTykZUWMdQUkEmzobHbDBfGBVe5XBwuypbgay m8Fm7Fi1K1Gn
cGggzWYma65VY3e21Koaoi0VbMtUG1Cl3qO93euYkB2707AlJiFYXqvEZ+9x 9liYsGfz51M0
2lgcXWapPR+lSQssmH7IGR9z/PSh62AGVUf2228mp0dkteD3b7/5AloZM4wi STOMCC6hZuy/
ePxPtPJrfTMeGxSDvoY+C0HIJrB3xEbHWnRCZhtwcRr4Mezx/mVeIKXpmZ/5 bzN/ea2k5Slg
EQ0fTY7HL6ZzHSWbz5SeIaBOjuFJDIZWcCPJRUpwkRGye3uPBvsPqAhUmeiK vtkNI3R6SM0g
buIp1rWAunyxSfKpjgUiKgLjXABELmvMeQ2pGXWBIboeUsnLMzBA0adUHQ7Z Fvb1fDJ/cX7K
Tq05+Dya9llEgmcF8trmMcEC09nheArG8jVsPLlHn9A0ymNQXcWHUL5SagcX jKot55KTgtP4
i+I/+YvIwh9DjTb8vWsRCI8GVwON9xM0oGGR0qTz3qvS6KrCH+IPB41qwKfG JWU5DicB4Jcq
hGhJa9SBRWz7CEPfLJBQsWRtDbbNCTDRVtpGsDlyioAQM8VH6ABXjfJzcC7t cIBOuYcwOaui
jkChFPoO8C096nichTjDcdWH85okpsS5syOxoku01z0PYx9FNyh10c9gk/jx WZpHSBbYCUPc
Eso/kK+naSsmNNDAkmjAY2MiZpXcc6C6LcYFC12jIloVjNnF9SWZtAS+gp0g YQdAAdjwMYh8
zvF9Y/ZgBQSw4C1+pGei8gB0vIFYLT8lb9j3P7DTk6ldoewM1waoM/iTb4og RUIq6PRbalLX
WPf86RPoln9MrQ7fsEo1ReHe56EQtba7UMhb3WuicP9uFIp25pmf5Es/C5Pg tmxw/019e/c3
bq80lOcfUmr8aeYvUDEtW7z/Rn190NTbh5/Q+plfgPKXhIuy2YdNbX33KW1l Yc69EyjJywa/
a2rw0SYNgrw3NosD1GWckFXqXuRhBnWxYknaIwdp9BfG1SXcgFh1mq2BurIt wBNDZCSoDZX7
a0puaf69KtGwsNMopGgj3lBIueebCOGrCLRy3BQ6cqNvESnt+EqBplA2y4B2 lKUEUij3m1De
b0epy44S6/0G2fGgHemRn1+TT6vE2CgQ1kBpoaus+RaWU1rr+iphjT1huHXx KKeqgSpbAF1l
3AjQDni4lo3GoNSwDxFX19slI4a31kPVmZ91qSa/hs/YqU1zS4irpVw9s1RU eECuIXIWFLqy
+/W83IIITqFFn5hB2xqxPOLOvhvWuxKRRs1uv4ZVVEPkXK9Dj6eBFivoneLe GKXV/vcqAhm1
a0DQoPIfB8ZWoxPvKMOWWU09bNVZtrMzi8MXSZSA+oqeI83j1tB97pozh6DG Rqw9XfhES0+Y
zG22FojCoEDhD/2W36umEi/Z06D2aqH2Naj9Wqj7GtR9G0pssV/SXtINpqEn ++TJIfAkZdtl
0Tnv0bYaMq0xPthSEW4wo4ZtlaoWk16l3TiygF2qPXNaH7ae3QF9vuNxbhwl 8MPyagpGHYmj
tOreo/EicafiVjEXbevIfZ7WILJzP25jdwDhYwG4RglHvWMxn6U6uqrU+AhE R4iOakccZ34N
nUn8JLg2lq9BAfsB42xKKjk4EtozOzccPOzfQz0yMM4BKt1UCHomgnvbw349 Elf3JeWq/y0H
is5BUKJO+d1EkdI25hWfo+RLVUWsEuU27FhOPJ37VZHg/nEcvU1uYN/ulEcX GvOfT6YTDIip
0IdFJOg1neaTj0ob+MTYC3gAjFAl4RNWbduKaPa0fQ4/20ZuNuRzGAJ2YBuR Ozsw83jAcDY5
JRC9kKpAA/Ml8Gh/ZBwlC6xiKA/4Bsz0P1E0suymiqGHWLgQdGLhRdTNp096 u96urrdU8Nnr
r5nEGoNPGBXY/ZGqvVuFaupmLR63EanjcRhcDjxu4xHw5BKPA8KBx20x6ngc hpUDj9tM1PE8
tCBsa4t9AnNwWuhnA3N8LgVIuB5qHMbke5CyqNlVXGLbUMmpq9es5zhcJhyJ 5TS5Z1SwXRt8
rGnf3d7jZ4KnKfOThc9mfy0bg+VKrWgtdJWGpFknCCgczeTqtM95670CnPc0 aUCUGUFIpd7E
hbcmz6WIF/K8TW86nbwC26PO/iJLB0WlCpImcdnB54PxchnDpOB84N7Id7Ie A2a7sqxzV2SO
u025YWuQsGt34XOF22s67LqNNMXqZBHyeZeV8k7frmQwdscwlDWrsIq0owoJ c6fG1HRUVEvQ
rGOEaNp1RGGnegQijqqN1o0wQ47KPFtnHQ6zHj4jFNSNToFwjE482kRyPNVw XDr3K5cwQe3q
hbBySmrtQrSeawtFEK+78HVDoYrvlYWm66aUqI7RqXpdSurM4049NNhRLAOE nRSScp2K+ljY
7Tas9nuOALhSIApoEeHmgP6xCbopFs69ypUF5hhZWtMNa1lbrLCLXkVx6I6+ E+i01cyRmssf
ie54dfWhgfd+XNwuw56Oqo/HFt1ZVwdlyvbT55C1KXKOOmaFFrnCNMHCvpBk +UySwJRQnyyg
/kMFy9qSo1kACYdzSd1XFizCa2GHuDbpEULTobBXGd7lscHxwL37as43o4oO XUbotTtav1C4
bYN8C/IoWfrFNcEWpckvdRyNEBEJo+hRvzlZInZGo420oq73XxXrhEgWpUg4 /8pckNghgVn0
SsTs8K7xmrqw/UN4syxue8kxNNFngzQbqEdzMzBCkD2y7DCqSa7cOC6y6KYH XNiDaREo+yaO
ecqZswIMjfXr3EpAJidJG6zaPcHmMajSYZ4+MZ5kEGqYetX3YGirnGExhiaM bZlP3EASC4k7
89HPV0NsOehUqS/OzzmG73/o/s3eg+wzke7hNdKMiGl/jtAdnWa3XY8jbLRS JQMrWk/TRmor
BzJqUL22IS3XSvuaY3VzX7vy3SHwjQYIgdB6aJZOHYEd7TasQhKNKOVtsVbB 5Ay9bzrPUfHT
EQquVNTXZPTOTss+Y26ppUXKNQ3bZ0BTpAlYarh0lqbqQCHhppQJKM/SAbLj UR9Z3wkBRvQH
P1vgnjAf1MC8yvwlAJycznvDfj0e9NZ6KED1peGGfu4XwfUhmNJWhQboV9dp HOLElFWaoKN4
EUC/8rWgL3CF5NPoXUlPA/Q4jpEO7LFEXx1/xamTj2GwKsKODnI0Y6+enUwn AlYe+KwSwypW
vGFNpnFLpLlFATBJFovS+X4uvRiChz3O05aLvmbd2NdRmv0JCo6fAjiVRdfy xlbGOXXWYSM4
wx8+37l+7LwGU+noybG8TGG6E5UXnO4XS5DT8fMJ646zyI+77OLkfyaoAGwP 99jsmHw3sraE
R/cPnvH0+qPDLPQLDHumyh4b7nlMuK0nmhNSyVDeLxzxPbNAjgGfDPPIq9CH q2/W40ODtaKr
ntSCPdRZ6JhAcrbj9KJsEn3u8od2mqd7UWFAJe2av7l8xNXlibavl2XD6nDM 2OH4YiJBycnM
YLdbWG5z2ObIGKTP7ZJIHQRr6T5wHibEce3ZuBSqntbhvgOdopk7rgXdo5G8 0UPMzMRVafi+
lYy12JOtkqWZmD3tco9kcp2dsV3vF48Y/lfvl91fPS1spd8QI/+JV76alPUr xe0C2yg4BpF0
6t+UyhtoBB+uo7i0K78nWiwdyLw82ZnfLkMpMHkyBNtJkfDoedp3xfctjTNC Q2ZKs9Ww2jTC
sPB76vFGZD2uUnXI2VF8a6Ko7srTmjfw6iX8hlfymuaXToChOx3U1M74vZIh HWfQYSAaQYfZ
9AqpF9iDl5g2AW9VBDhYFkKfMwzhoUsP1CnZyq7dPPJSArwEyPhROXwhgVcO z0kBtmwAX17A
KsmQD3DMwPR5F6arwkJYHownKJw9vkFbQOVZAI8eKUN/poRdPC4cNSl+gmuC hpIHj3XNQIzF
BXdj/YI2a7cLoxEnUHAZKteDbp/9fz5YVr8lX4znPZHZw2MXq0uYjp7Fg2d0 g6wckqC8iVRb
QfDdNt5vKJtETFvUyaRKR9FTWUTWpkQw8KeSYvgAeqqDBwfVnCGGDPFzPxbR YpZTVCx4Xw/C
sWdAyjRyfFlGMfQmr/aG7q3hjRGgTI6VZR/LjtnH1eHHyLiXYxND8yqWsBjO OgLETEmOcYCJ
eQKlyxwva6434Lk67kGyRQjQfwDRBtkkHP/TqCZRjnhBPX3vx73PRnuf0RaF 8pXf6PzyXeHb
0e+kM2pL/Z30h6sFs1Xx++iP7y8WPaVSeeyXT9SXYGB+1d0cQmEtPSN3CZHh ypKs4wqRwQG4
TD920CJFHxWpK33+FRQb8Y3Uj229jOss2wTz28cJCww1dygpMNh1P2bXDSRy JZjlU0rE5m7R
vuNEwK0takDOFss74dUWiW8zYDajWYK1aSwvlVMtco06mETdWeBs1e0ro5op xSZkPW5YtKhn
Q1qXf3CrNKALcRyg8qh8cHQyoz8m/0/lKWWWs/QgFz4LBP6Sf4gQV6D8ZZPk YVvDjYVPtbnR
SAUFL9KgJ1u3IR1XsO3+4EA4unMljB0hRWuk2ZayF4FOJ6E8FppzIToO8E6W kGk/USOe6+Kc
WQ9NZqgHMp3IservvemDdQ/C2V12b3tYV2QL42rLKFarFN9vpZjL4WpN17U2 s6YS3NXKrour
1kCRpJ9fZ+nq7XUVgeMi6hoM4loTjLvTUkpS85VYXuso68hrjRoV63Ttk/Zq Vm9ROK7LfnJT
6HqRCA7Pp8ebVcdwWqTgwBnPTMG2iN9dXCV/HSMbDeYqrtqbxLIFTsiWs65j Ct34jA5xuc5/
/1CZK/WnNh3VK+SjK1O+bW9LXwDfdn7gmUX39+pvN2t+QP2PY7rTAJ1vNECO Z9zV1+7y6Js6
KKu90JjeLFdFeIEpImDjCfKut1dRjOFP83lVU9BoATldB/uKutVOkw+F36XL pSDRZg4m6r5r
crRq8uuWEwF74FXZvpRXCqrvFFPrNyM4DAfegcd2vzCnB2azubVn1vR/cwd4 IRzgcyFT15WA
dvw9Ny40/Relt7IMzjFVgq4l2jeu1/DPiktgtsvct6+PiTR0NYFY9lVkGbN9 ejK1Qra1xHVN
94leRcmCR4k5ovn4bw5SdRqnL6MQI9BwuXAYXg0VeCPOiwDlph+G76iYgYTa 1ZLD7OywxyIH
GhbwPGhaz7V4iKpXW8+d1nFMEyfP45S0DZuW1a9p5DC8EKBXS/fgdVW5fqdA PRT23Yynv+Mm
XXfYddCuqrjodqQb/Mqzve5k75rRrfZsVkMo7zZ5ZWrFrzx3uy1z10g1Jn1s X/H8HKYBUZkn
0olMHN3IuNRKPha90I5ptrb96nEkz06LM/3Qmm0n+EmSh1nxJAv9d5022Kdp kZ6ioGceG9rA
FOa7tWU95FdzDnatx+LgtXxsx2rzg1A8T90f9ikp4iRnSRiEuZ9FKVv6Gb4y Aa0e9j5KglXs
Z8BTOeOJ8SjDPB2gM57hEEYygo8y86Y/+NbaAOwz07qUnk3svJS3UuVmXWar E4CtGfxKJjdQ
uXUhdzo+qj93peS7akjJp9fSMkXwEXCtqfbO1o+sMwtq01qpHHPSSzMoxgO+ NN5tNcQKlxhH
4ZW/igsxAhjfS+haz9F/68SslRGampeRhfIjLv7L68io7hyKc23PcOAZwcw8 4mTPiwMQ3b6e
ilIoZLwxDDWR5/wAhIGE8O2aXMu8j+aRtSq8TD/yamWKAjvMCc+uRRw1HVSL 7+JQGmNId+Uo
y198rCnEmnUNbDLsCopk2BXdUC5DabBIuzWs3TjHhg1kTVka9ZgyDDfHsFV9 2kTwK+HTBkqP
kFEJDggIo6b0+j+Uwd/G85EVJCVEjBklxWRsk+xb5cxWzuheQ5U9d5VhQ5WH 7ipK5k/M672O
rKWsJZyhJZphjWCG5liGiWk53eGsY6OjDn1u73zqobW91mmERelGZySbHJHI Ojs72LT8dTw7
b8sNWWVnxu6QF3LDtCzVaq50i1Un9ObpIBsIa8oFuWkeyM2zQGpnT+smf9w8 9ePnSfu4edLH
uyR83Dzdo9nKJrkeN8/0aLe1XoJFSwifTl7PmX6kvLPD4zPx3U0gB9IsUTqq nS1Aly/a4WP9
Uq9kWGxZ6tUub5ZZsSGvoo5pzaSKDSkVTWxr5VNsyKZoYlszlWJD1kMT31pZ FNfG1pxA0WY2
kT2xsgmtf7h8p7NlrhCXlTRwisq0APVjSMaUVl9GNduY9fNHrIB7tKXo9VlN JTo61FvhgVD4
567AOYuVNoY1OGJmus+g2RibLnMcdktzxF1JXU/hOnYJo6V6sgawNtVTc6Yn 1A2No33QBjW1
WtfYlDFhRgfb2ggf565ufeisePcDijsdTphUa7+2mOAImrqdnS37rYzluHnd iyVw3JMQ7O2w
a8lNCvCUpJFDSewbWlvf12ZG33z8TE6pY5RPHeu7DvcXH3GQZEdaGNTE9Mr9 tsxlZvu3bBhu
3COcdVAmrH+6oVrorijFXLwm5yp5l5ZX0onR8ByFMV6Px8ubLkiNf7r4tSsv vey1LdT1hlL1
dM2RtObUcX8/L9CnncibVcpjwrolFrBhUy1lQHWgoUPi5YZEG78yIAur773w 2Ez5cbTkwTLx
qO7a0fqp3DyGRHXY11oKg5J3zNSMk+pJs7NWheOUg7ySZNj1RqH1E+N2VPWO dT+43iVvvaCo
6VawdcxROkfvdGjTfFxjA8qbt6s4vgiyEFOqWJd4a3M1CMYRZzPyqdONecdb RjUv2hHD5rzn
YilUrrgu0TpzA4kgLqKsBkREW3FFyQ0yublMc7x7KvpUA6bCg9S1Kp0RG659 2dte7bG1glCJ
LPlZtGOx5CjcAnpdMx3PLSrSlLc31VMAZZTfQS+W4ltIbIBTZIo6IsoAfmEQ BFpmCLRdunlA
cmgwCsJjQ4xvpjOaPZHFogWO3l+spIgeq1B6MJUYrknriu/zem68z8vkTMTm eIWWyhUiKqGj
VrxxrMzxI/RePDDljXBgSmVhvJS65oqzqCWmWly95FeBFf11rxdr6QI1u3NP jNeHBR7pHq4y
sAPppJHjg5IhV4krAOJEH/4eawAw2ElaWC9VfaQDvA/pYC9XDcDfQxdA2QAT JjEHOI6y3CQR
/h64AHQMezoAVKxQ+Z0GII7cKa+VAtDH4QxWhZ/d6hQwYWkbADoFTDgc8N3d 4oGxQWy4D4i6
6+4G6khE8Aew62PnVqGO9j3zjehi5ZYcRiFuHjPT1zQFACAws/+ALZ9m/qVP h60LeukbSBGV
VVBHvlGoiHjx3fgyC1kYsxt6dTw/5g3zAParVaa/K8EdkVCRoS3v5muXGtrM HdEL+qynIq10
coIZgDwWoeFO7obKRAYy2VAHM60NPsZ5R99cVN6v0l4wqUYXHsfh0TwOjk2t QH9HNB/sEiXt
xGU5ZQXjb2rPwtzH8a5/l7TdhHiTM2+iBCvb4ACd/jpNcFi9Ce1F0c5elNgl OzY0IdErsSnD
3vD28jNQwMsp4DNY9opXHR2mKzw4FE0dhe9XYfw+xCiDBFlfvM7+unxRuWhg 64BNaSum2DqO
vN8H27Mj6xBrB44XguP7wDtbFLvL+IfCjS7UiI7d6OQSsRqrWfBotRsI2YOq /XXnxECrukSd
QSzQj8E2ECkaHKEq1+vb5KIzWZtbqXVyPWBLfgr0lFZ2p34NV96UeTe9tXWZ q3xbjZl7OHAC
2yeJcirmDAqPOhWpbwQcCmgQ3xwrR+PxD11H5Cq13YClUZfyRZ12d+b+dXrj d5y5ykiRZvz0
XDxzgEmvIz/OrgcT6nQLmJgIcar+uzAG5MLiwpqS30rRzwV1GDsmsyGS1TAI tG2kcUXI17Gq
16+utaNtwulrMrpMqIX0IPGHYKzITzko9INCdMuMGgK9/jZZDrC6SXLh34AP RZ4ZlaLj+Aj1
lRQmhKODKb5fVo6NKsNGjDLjqKhtdQoo6qlQamgS6ljBelWuwoCy/GMpyxFI XzdYfFsWY117
WfFBJv87EYM/e3wcKsfF2kSQQwx+VWRaBbRURXiQ4PgKVLWuetvvTx+9W+uk SJf4/LsaMDGn
owNJrfjNp7YkQ2PF9sTPfFEdaHV4oI9ZjrJldNDlUrFrlqEoGR0Md1vpxKTd x/xN4TpsBY62
2tLMJRi7j2ru93FyjTO1epym+92JlwrKsxkKODEiVBrexGFUdRzRaDdXrJnl tNL4ENLe3n7f
Kbd2drY/6x/iPH5xejg/mZ3yOC661oV5N/FzT3zuuxyDX5SWMh0lC/DjuZ+/ Y0Lp5l4N1P+K
a5ZeMZ8yLyeUHEnz55DFdI73STp/w32xRAM/jqL8nQYbnBNOLXhMf02NKEV8 L5ZL9Dlg5JBG
GYgmdRNsMtXSa5UVe7xNOhzAvsGPwOwbKn8nVz32BzYhP5OoANQS/R251U1O j06Ode6QrXyl
WRGJN8150aaFgviK61DNCktSxpPOrjU7rdMij+XY94y2ILuuOfDn/CVM2lzZ lfAozzF50FyP
qat4nZFJJd1I089O79qk1aqJSVVxOPkkG7gYVDzo/4ZsUmVwnUkWWQRGICxe ZBSVkdiYdTIx
O3Lur9yzcKDnn2tfpnvlMrWPWLTh+T9QSwECFAAUAAIACAA2ex031XbrGF0f AADDkAAACgAA
AAAAAAAAACAAAAAAAAAAVHdvcmRYLnByZ1BLBQYAAAAAAQABADgAAACFHwAA AAA=
--------------010302090201080702030603--
Jose David Angulo Urzola
Auditoria y Sistemas Ltda.
Cartagena-Colombia
Xevi
Mensajes: 1706
Registrado: Jue Sep 08, 2005 12:58 pm

Word desde Xailer.

Mensaje por Xevi »

José David,
esta clase compila perfectamente... Ahora bien, ¿podrí­as ponerme algun ejemplillo de como utilizarla???
O si puedes ponerme una cuantas lí­neas de tu código... para ver como la utilizas.
Gracias.
Un Saludo,
Xevi.
"José David Angulo" <gerencia@microexpressltda.com> escribió en el mensaje news:[email=48d11fb5@ozsrv2.ozlan.local...]48d11fb5@ozsrv2.ozlan.local...[/email]
Xevi,
Esta es la que uso con Xailer no se si es la misma, mira a ver si te sirve.
--
José David Angulo.
Auditorí­a y Sistemas Ltda.
Tel.(57) 5- 6643022 - 6644555
Cartagena - Colombia
jose.angulo@auditoriaysistemas.com
Xevi escribió:
Rene,
He intentado añadir esta clase a un proyecto hecho con Xailer...
donde #include "elotroproducto.ch"... "Xailer.ch"
Y lanza una pila de errores al compilar.
He intentado "depurarlo... pero me atasco en alguna parte.
Gracias.
Un Saludo,
Xevi.

--
Xevi
Mensajes: 1706
Registrado: Jue Sep 08, 2005 12:58 pm

Word desde Xailer.

Mensaje por Xevi »

Gracias...
Es SuperFacil utilizando la Clase TWordX !!!
Local oWord := TWord():New()
oWord:OpenDoc( "C:test.doc" )
oWord:Replace( "<NOMBRE>", "NOMBRE y APELLIDOS DE PRUEBA" )
oWord:Visualizar()
Un Saludo,
Xevi.
"Xevi" <xevicomas_quitar_esto@gmail.com> escribió en el mensaje news:48d23e57$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
José David,
esta clase compila perfectamente... Ahora bien, ¿podrí­as ponerme algun ejemplillo de como utilizarla???
O si puedes ponerme una cuantas lí­neas de tu código... para ver como la utilizas.
Gracias.
Un Saludo,
Xevi.
"José David Angulo" <gerencia@microexpressltda.com> escribió en el mensaje news:[email=48d11fb5@ozsrv2.ozlan.local...]48d11fb5@ozsrv2.ozlan.local...[/email]
Xevi,
Esta es la que uso con Xailer no se si es la misma, mira a ver si te sirve.
--
José David Angulo.
Auditorí­a y Sistemas Ltda.
Tel.(57) 5- 6643022 - 6644555
Cartagena - Colombia
jose.angulo@auditoriaysistemas.com
Xevi escribió:
Rene,
He intentado añadir esta clase a un proyecto hecho con Xailer...
donde #include "elotroproducto.ch"... "Xailer.ch"
Y lanza una pila de errores al compilar.
He intentado "depurarlo... pero me atasco en alguna parte.
Gracias.
Un Saludo,
Xevi.

--
Avatar de Usuario
gerencia
Mensajes: 282
Registrado: Sab Jun 20, 2009 6:01 pm

Word desde Xailer.

Mensaje por gerencia »

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000066">
Xevi,<br>
<br>
La estoy utilizando conjuntamente con la clase TExcelScript y lo que
hago es combinar correspondencia yo le dejo todo el trabajo a Word que
cambie los datos del documento modelo, solo le envià la hoja de excel
con los datos y listo, si el usuario es un genio con Word y Excel que
arme su archivo con word y yo le mando los datos con combinar
correspondencia en Word. <br>
<br>
<br>
Function combinarCorrespondencia(cFileWord, cFileXLS)<br>
ÂÂ Local oWord<br>
<br>
ÂÂ oWord := TWord():New()<br>
<br>
ÂÂ oWord:OpenDoc(GetCurrentDirectory()+"Documentos"+cFileWord) <br>
ÂÂ
oWord:OpenDataSource(GetCurrentDirectory()+"Documentos"+cFileXLS)//
Abre el origen de datos para la combinaciÃn de correspondencia<br>
ÂÂ //oWord:oMailMerge:Set( "Destination" , 1 )ÂÂÂ // A la impresora<br>
ÂÂ oWord:oMailMerge:Set( "Destination" , 0 )ÂÂÂ // Nuevo documento<br>
ÂÂ oWord:oMailMerge:Invoke( "Execute" )<br>
<br>
ÂÂ oWord:Preview()<br>
ÂÂ oWord:Close()<br>
Return NIL<br>
<br>
<br>
-- <br>
<div class="moz-signature">
<meta http-equiv="CONTENT-TYPE" content="text/html; ">
<title>Josà David Angulo</title>
<meta name="GENERATOR" content="OpenOffice.org 2.0 (Win32)">
<meta name="CREATED" content="20061023;14550935">
<meta name="CHANGEDBY" content="Jose Angulo">
<meta name="CHANGED" content="20061023;14593800">
<meta name="ProgId" content="Word.Document">
<meta name="Originator" content="Microsoft Word 9">
<style>
<!--
P { color: #000000 }
-->
</style>
<p style="margin-bottom: 0cm;"><font size="2"><span
style="background: transparent none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b><font
face="Century Gothic"><font color="#000080">JosÃ
David Angulo.</font></font></b></span><font face="Arial"><font
color="#0000ff"><br>
</font></font></font><font face="Arial"><font color="#0000ff"><b><font
style="font-size: 11pt;" size="2">A<span lang="en-GB">uditorÃa
y Sistemas Ltda. </span></font></b><br>
<font style="font-size: 8pt;" size="1">Tel.</font></font></font><font
size="1"><font face="Century Gothic"><font color="#808080">(57)
5- 6643022 – 6644555</font></font></font></p>
<p style="margin-bottom: 0cm;"><font size="1"><font
face="Century Gothic"><font color="#808080">Cartagena - Colombia</font></font></font><br>
<a href="mailto:Gerencia@microexpressltda.com"><font
style="font-size: 9pt;" size="2">jose.angulo@auditoriaysistemas.com</font></a></p>
<p style="margin-bottom: 0cm;"><br>
</p>
</div>
<br>
<br>
<br>
<br>
Xevi escribiÃ:
<blockquote cite="mid:48d23e57$1@ozsrv2.ozlan.local" type="cite">
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.5512" name="GENERATOR">
<div><font color="#000000" face="Arial" size="2">Josà David,</font></div>
<div>Â</div>
<div><font color="#000000" face="Arial" size="2">esta clase compila
perfectamente... Ahora bien, ÂpodrÃas ponerme algun ejemplillo de como
utilizarla???</font></div>
<div><font color="#000000" face="Arial" size="2">O si puedes ponerme
una cuantas lÃneas de tu cÃdigo... para ver como la utilizas.</font></div>
<div>Â</div>
<div><font color="#000000" face="Arial" size="2">Gracias.</font></div>
<div>Â</div>
<div><font color="#000000" face="Arial" size="2">Un Saludo,</font></div>
<div><font color="#000000" face="Arial" size="2">Xevi.</font></div>
<div>Â</div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Josà David Angulo" <<a moz-do-not-send="true"
href="mailto:gerencia@microexpressltda.com">gerencia@microexpressltda.com</a>>
escribià en el mensaje <a moz-do-not-send="true"
href="news:48d11fb5@ozsrv2.ozlan.local">news:48d11fb5@ozsrv2.ozlan.local</a>...</div>
Xevi,<br>
<br>
Esta es la que uso con Xailer no se si es la misma, mira a ver si te
sirve.<br>
<br>
<br>
-- <br>
<div class="moz-signature">
<meta content="OpenOffice.org 2.0 (Win32)" name="GENERATOR">
<meta content="20061023;14550935" name="CREATED">
<meta content="Jose Angulo" name="CHANGEDBY">
<meta content="20061023;14593800" name="CHANGED">
<meta content="Word.Document" name="ProgId">
<meta content="Microsoft Word 9" name="Originator">
<style>P {
COLOR: #000000
}
</style>
<p style="margin-bottom: 0cm;"><font size="2"><span
style="background: transparent none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><b><font
face="Century Gothic"><font color="#000080">Josà David Angulo.</font></font></b></span><font
face="Arial"><font color="#0000ff"><br>
</font></font></font><font face="Arial"><font color="#0000ff"><b><font
style="font-size: 11pt;" size="2">A<span lang="en-GB">uditorÃa y
Sistemas Ltda. </span></font></b><br>
<font style="font-size: 8pt;" size="1">Tel.</font></font></font><font
size="1"><font face="Century Gothic"><font color="#808080">(57) 5-
6643022 – 6644555</font></font></font></p>
<p style="margin-bottom: 0cm;"><font size="1"><font
face="Century Gothic"><font color="#808080">Cartagena - Colombia</font></font></font><br>
<a moz-do-not-send="true"
href="mailto:Gerencia@microexpressltda.com"><font
style="font-size: 9pt;" size="2">jose.angulo@auditoriaysistemas.com</font></a></p>
<p style="margin-bottom: 0cm;"><br>
</p>
</div>
<br>
<br>
<br>
Xevi escribiÃ:
<blockquote cite="mid:48d113f0@ozsrv2.ozlan.local" type="cite">
<pre wrap="">Rene,
He intentado aÃadir esta clase a un proyecto hecho con Xailer...
donde #include "elotroproducto.ch"... "Xailer.ch"
Y lanza una pila de errores al compilar.
He intentado "depurarlo... pero me atasco en alguna parte.
Gracias.
Un Saludo,
Xevi.
</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
<br>
<div class="moz-signature"><br>
</div>
</body>
</html>
Jose David Angulo Urzola
Auditoria y Sistemas Ltda.
Cartagena-Colombia
Vikthor
Mensajes: 18
Registrado: Jue Nov 16, 2006 4:31 pm

Word desde Xailer.

Mensaje por Vikthor »

José David Angulo
La clase TExcelScript es únicamente para uso exclusivo con el "otro" producto.
Las modificaciones hechas por un servidor a la clase TWord son también para uso exclusivo del "otro" producto.
Atentamente :
Un usuario del "otro" producto.
jajajajajajajajajajajajaja, perdón , perdón , perdón............pero no me pude contener.
Un saludo a todos por acá.
Después de varios años usando el "otro" producto, hoy comienzo mi camino de la mano de Xailer.
Dicho lo cual....... ustedes tranquilos y yo sereno, que ya andaré dando dejando mis dudas en este foro lleno de amigos.
Vikthor
Posdata :
¿ Aquí­ no me van a censurar ?
"José David Angulo" <gerencia@microexpressltda.com> escribió en el mensaje de noticias news:[email=48d25301@ozsrv2.ozlan.local...]48d25301@ozsrv2.ozlan.local...[/email]
Xevi,
La estoy utilizando conjuntamente con la clase TExcelScript y lo que hago es combinar correspondencia yo le dejo todo el trabajo a Word que cambie los datos del documento modelo, solo le envió la hoja de excel con los datos y listo, si el usuario es un genio con Word y Excel que arme su archivo con word y yo le mando los datos con combinar correspondencia en Word.
Function combinarCorrespondencia(cFileWord, cFileXLS)
Local oWord
oWord := TWord():New()
oWord:OpenDoc(GetCurrentDirectory()+"Documentos"+cFileWord)
oWord:OpenDataSource(GetCurrentDirectory()+"Documentos"+cFileXLS)// Abre el origen de datos para la combinación de correspondencia
//oWord:oMailMerge:Set( "Destination" , 1 ) // A la impresora
oWord:oMailMerge:Set( "Destination" , 0 ) // Nuevo documento
oWord:oMailMerge:Invoke( "Execute" )
oWord:Preview()
oWord:Close()
Return NIL
--
José David Angulo.
Auditorí­a y Sistemas Ltda.
Tel.(57) 5- 6643022 - 6644555
Cartagena - Colombia
jose.angulo@auditoriaysistemas.com
Xevi escribió:
José David,
esta clase compila perfectamente... Ahora bien, ¿podrí­as ponerme algun ejemplillo de como utilizarla???
O si puedes ponerme una cuantas lí­neas de tu código... para ver como la utilizas.
Gracias.
Un Saludo,
Xevi.
"José David Angulo" <gerencia@microexpressltda.com> escribió en el mensaje news:[email=48d11fb5@ozsrv2.ozlan.local...]48d11fb5@ozsrv2.ozlan.local...[/email]
Xevi,
Esta es la que uso con Xailer no se si es la misma, mira a ver si te sirve.
--
José David Angulo.
Auditorí­a y Sistemas Ltda.
Tel.(57) 5- 6643022 - 6644555
Cartagena - Colombia
jose.angulo@auditoriaysistemas.com
Xevi escribió:
Rene,
He intentado añadir esta clase a un proyecto hecho con Xailer...
donde #include "elotroproducto.ch"... "Xailer.ch"
Y lanza una pila de errores al compilar.
He intentado "depurarlo... pero me atasco en alguna parte.
Gracias.
Un Saludo,
Xevi.

--
Bingen Ugaldebere
Mensajes: 1310
Registrado: Mié Sep 26, 2007 7:12 pm

Word desde Xailer.

Mensaje por Bingen Ugaldebere »

/*
* Proyecto: Microsoft Word Management Class via OLE
* Fichero: TWord.prg
* Autor: Bingen Ugaldebere - Mungia Informática
* Based in a original class for FW 16bits from Sebastian Almirón
* Fecha: 21/08/2007 - 10/09/2007
*/
#include "Xailer.ch"
#include "tWord.ch"
CLASS TWord
Data oWord
Data cDocName
Data OleDocs
Data lInstalled Init .T.
Data OleDocs
Data oDocument
Data oText
Data oSelection
Data oRange
Data cDocName
Data nLine,nCol, nPage
Data nYoffset, nXoffset
Data lStartpag
Data lOverflowing
Data nlastrow
Data cTextOverflow
Data lSetCm
METHOD New()
METHOD NewDoc( cDocName, cTemplate )
METHOD View()
METHOD Hide()
METHOD OpenDoc( cDocName, lReadonly )
METHOD Preview()
METHOD SetLandScape()
METHOD SetPortrait()
METHOD Setpaper(nWidth, nHeight, lLandscape)
METHOD CloseDoc(oDoc)
METHOD End()
METHOD CheckSpelling()
METHOD GoBottom()
METHOD Gotop()
METHOD GoEnd()
METHOD GoInit()
METHOD GoUp(nLines)
METHOD GoDown(nLines)
METHOD Goto(nLin,nCol)
METHOD GoRight(nChar)
METHOD GoLeft(nChar)
METHOD GotoPage(nPage)
METHOD GotoHeader()
METHOD GotoFooter()
METHOD GotoDocument()
METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo, nItem, nCopias, cPages)
METHOD Protect(cPassword,nMode)
METHOD UnProtect(cPassword)
METHOD Save(cDocName)
METHOD Say( nLin,nCol,cText,oFont,nSizeHorz,nClrText,nBkMode,nPad, nAltura, nClrIndex, lVertAdjust )
METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor )
METHOD SetCm()
METHOD GetTextHeight( oFont )
METHOD GetTextWidth(cText, oFont)
METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext, nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation)
METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo, nrotacion )
METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo, nrotation, lPicTextured )
METHOD FullView()
METHOD Pages()
METHOD Find( cText )
METHOD Replace( cOld, cNew )
METHOD ReplaceFields(aDatasets)
Method ReplaceArrays(aDatasets,nColumnaInicial)
METHOD ListOfFields(aDatasets,lShow)
METHOD NewPage()
METHOD SelectAll()
METHOD SelCurrentLine()
METHOD SelCurrentPara()
METHOD UnSelect()
METHOD Cut() INLINE ::oText:Cut()
METHOD Copy() INLINE ::oText:Copy()
METHOD Paste() INLINE ::oText:Paste()
ENDCLASS
METHOD NEW() CLASS TWord
TRY
::oWord := GetActiveObject( "Word.Application" )
CATCH
TRY
::oWord := CreateObject( "Word.Application" )
CATCH
::lInstalled := .F.
END
END
Return Self
//Document management__________________________________________________ ________
METHOD NewDoc( cDocName, cTemplate ) CLASS TWord
DEFAULT cDocName TO "Documento1"
DEFAULT cTemplate TO ""
::oWord:Documents:Add(cTemplate)
::OleDocs := ::oWord:Documents
::oDocument := ::oWord:ActiveDocument
::oText := ::oWord:Selection
::cDocName := cDocName
::nLine := 0
::nCol := 0
::nPage := 0
::nYoffset := 0
::nXoffset := 0
::lstartpag := .t.
::oSelection := ::oDocument
::oRange := ::oDocument:Range(1,1)
::lSetcm := .f.
::lOverflowing := .f.
::nlastrow := 0
::ctextoverflow := ''
Return Nil
METHOD OpenDoc( cDocName, lReadOnly )
Local lOk := .t.
Default lReadOnly To .F.

::OleDocs := ::oWord:Documents
If File( cDocName )
::cDocName := cDocName
::oDocument := ::Oledocs:Open(::cDocName,,lReadOnly)
if valtype(::oDocument) <> 'O'
lOk := .f.
else
::oText := ::oWord:Selection
::nLine := 0
::nCol := 0
::nPage := 0
::nYoffset := 0
::nXoffset := 0
::oSelection := ::oDocument
::oRange := ::oDocument:Range(1,1)
::lstartpag := .t.
::lsetcm := .f.
::lOverflowing := .f.
::nlastrow := 0
::ctextoverflow := ''
Endif
else
MsgStop("Word File Not Found"+CRLF+CRLF+cDocName )
lOk := .f.
endif
Return lOk
METHOD Save(cDocName) CLASS TWord
DEFAULT cDocName To ::cDocName
::oDocument:SaveAs( cDocName )
Return Nil
METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo, nItem, nCopias, cPages) CLASS TWord
Local Csinpath, cPath
DEFAULT lBackground To .f.
DEFAULT lAppend To .f.
DEFAULT nRange To 0
DEFAULT cOutputFile To ''
DEFAULT nFrom To ''
DEFAULT nTo To ''
DEFAULT nItem To 0
DEFAULT nCopias To 1
DEFAULT cPages To ''
If !Empty(nFrom) .Or. !Empty(nTo)
nRange := 3
nFrom := Alltrim(Str(Int(nFrom)))
nTo := Alltrim(Str(Int(nTo)))
Endif
If Empty(cOutputFile)
::oDocument:PrintOut(lbackground,lappend,int(nRange),'',nfro m, nto, nitem,ncopias, cpages )
Else
cPath := FilePath(cOutputFile)
If !Empty(cPath) .and. cPath <>''
::OleWord:ChangeFileOpenDirectory(cPath)
Endif
cSinpath := FileFullName(cOutputFile)
::OleWord:PrintOut(lbackground,lappend,int(nRange),csinpath, nfrom, nto, nitem, ncopias, cpages )
Endif
Return Nil
METHOD CloseDoc(oDoc,lSaveChanges) CLASS TWord
DEFAULT oDoc To ::oDocument
DEFAULT lSaveChanges To .F.
oDoc:Close(If(lSaveChanges,0,-1)) // 0=Close without save changes -1=Close saving changes
Return Nil
METHOD End(lSaveChanges) CLASS TWord
DEFAULT lSaveChanges To .F.
::OleDocs:Close(,lSaveChanges)
::oWord:Quit()
::oText := NIL
::oDocument := NIL
::OleDocs := NIL
::oWord := NIL
Return nil
//Presentation Management__________________________________________________ _____
METHOD View(nView) CLASS TWord
Default nView To 1
::oWord:Visible := .T.
::oWord:WindowState := 2
::oWord:WindowState := nView // 1=Maximize 2=Minimize 3=Normal
Return Nil
METHOD Hide() CLASS TWord
::oWord:Visible := .F.
Return Nil
METHOD FullView() CLASS TWord
LOCAL oWindow, oView
oWindow := ::oDocument:ActiveWindow
oView := oWindow:View
oView:FullScreen:=.T.
::View()
release oView
Return nil
METHOD SetPortrait() CLASS TWord
Local oPageSetup := ::oDocument:PageSetup
oPageSetup:Orientation:=wdOrientPortrait
release oPageSetup
Return Nil
METHOD SetLandScape() CLASS TWord
Local oPageSetup := ::oDocument:PageSetup
oPageSetup:Orientation:=wdOrientLandscape
release oPageSetup
Return Nil
METHOD Setpaper(nWidth, nHeight, lLandscape) CLASS TWord
Local oPage
DEFAULT nWidth To 21
DEFAULT nHeight To 29.7
DEFAULT lLandscape To .F.
oPage := ::oDocument:Pagesetup
If lLandscape
oPage:Orientation:=wdOrientLandscape
Else
oPage:Orientation:=wdOrientPortrait
Endif
oPage:PageWidth :=nWidth*28.35
oPage:PageHeight :=nHeight*28.35
release opage
Return Nil
METHOD Preview() CLASS TWord
::oWord:PrintPreview()
::oDocument:PrintPreview()
::View()
Return nil
//Positioning_______________________________________________ ___________________
METHOD Gotop() CLASS TWord
::oText:HomeKey(wdStory,wdMove)
Return nil
METHOD GoBottom() CLASS TWord
::oText:EndKey(wdStory,wdMove)
Return nil
METHOD GoInit() CLASS TWord
::oText:HomeKey()
Return nil
METHOD GoEnd() CLASS TWord
::oText:EndKey()
Return nil
METHOD GoDown(nLines) CLASS TWord
Default nLines To 1
::oText:MoveDown(wdLine,nLines,wdMove)
Return nil
METHOD GoUp(nLines) CLASS TWord
Default nLines To 1
::oText:MoveUp(wdLine,nLines,wdMove)
Return nil
METHOD GoRight(nChar) CLASS TWord
Default nChar To 1
::oText:MoveRight(wdCharacter,nChar,wdMove)
Return nil
METHOD GoLeft(nChar) CLASS TWord
Default nChar To 1
::oText:MoveLeft(wdCharacter,nChar,wdMove)
Return nil
METHOD Goto(nLin,nCol) CLASS TWord
Local n:=1, oProperties,oLines
Default nCol to 1
CursorWait()
oProperties:=::oDocument:BuiltInDocumentProperties
oLines:=oProperties:Item(wdPropertyLines)
If oLines:Value>nLin
::Gotop()
::GoDown(nLin-1)
Else
For n=1 to nLin-oLines:Value
::oText:TypeText( Chr(13) )
::GoBottom()
Next
Endif
::GoInit()
::GoRight(nCol-1)
CursorArrow()
Return nil
METHOD GotoPage(nPage) CLASS TWord
Local n:=1
Default nPage To 1
::GoTop()
For n:=1 to nPage-1
::oText:GotoNext(wdGoToPage)
Next
Return Nil
METHOD GotoHeader() CLASS TWord
Local oWindow := ::oDocument:ActiveWindow
local oView := oWindow:View
oView:SeekView:=wdSeekCurrentPageHeader
::oSelection := ::oText:HeaderFooter
release oWindow, oView
Return Nil
METHOD GotoFooter() CLASS TWord
Local oWindow := ::oDocument:ActiveWindow
local oView := oWindow:View
oView:SeekView:=wdSeekCurrentPageFooter
::oSelection := ::oText:HeaderFooter
release oWindow, oView
Return Nil
METHOD GotoDocument() CLASS TWord
Local oWindow := ::oDocument:ActiveWindow
local oView := oWindow:View
oView:SeekView:=wdSeekMainDocument
::oSelection := ::oDocument
release oWindow, oView
Return Nil
//Other features
METHOD CheckSpelling() CLASS TWord
::oDocument:CheckSpelling()
Return nil
METHOD Protect(cPassword,nMode) CLASS TWord
DEFAULT nMode To 3
If cPassword=Nil
Msginfo("ERROR: Imposible proteger Documento sin un paswword")
Return .F.
Endif
::oDocument:Protect( nMode, .F. , cPassword )
Return .T.
METHOD UnProtect(cPassword) CLASS TWord
::oDocument:UnProtect( cPassword )
return nil
METHOD SetCm() CLASS TWord
::lSetCm := .t.
Return Nil
METHOD GetTextHeight( oFont ) CLASS TWord
Local nHeight
If ::lsetcm
nHeight := oFont:nHeight/28.35
Else
nHeight := oFont:nHeight
Endif
Return nHeight
METHOD GetTextWidth(cText, oFont) CLASS TWord
Local nWidth
If oFont:nHeight > 0
nWidth := (oFont:nHeight/1.6)*len(ctext)
Else
nWidth :=((oFont:nHeight*-1)/1.6)*len(ctext)
Endif
Return nWidth
METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext, nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation) CLASS TWord
local oShapes,oCuadro,oFill,oLine, oFontC, oText, oCuadroText, cText2, lCorta, oParagraph, oFillColor
local nPad := 0, n, oWrap, nheighttext, lnocabe := .f., nheightbox:= 0
DEFAULT nTop To 0
DEFAULT nLeft To 0
DEFAULT nBottom To 10
DEFAULT nRight To 10
DEFAULT cText To ' '
DEFAULT oFont To TFont():New()
DEFAULT nClrText To RGB(0,0,0)
DEFAULT nJustify To 0
DEFAULT afondo To {}
DEFAULT aLine To {}
DEFAULT lvertadjust To .f.
DEFAULT nOrientation To 1
nheighttext := oFont:nHeight
If nOrientation > 3
nOrientation := 1
Endif
do case
case nJustify = 1
nPad := 2
case nJustify = 2
nPad := 1
case nJustify = 6
nPad := 0
endcase
if ::lsetcm
nTop := nTop*28.35
nLeft := nLeft*28.35
nBottom := nBottom*28.35
nRight := nRight*28.35
endif
oShapes := ::oSelection:Shapes
oCuadro := oShapes:AddTextbox( nOrientation,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBot tom-nTop) )
oFill := oCuadro:Fill
// OleSetProperty( oCuadro, 'RelativeHorizontalPosition',1)
// OleSetProperty( oCuadro, 'RelativeVerticalPosition',1)
//Fill
for n = 1 to len(afondo)
do case
case n = 1 .and. afondo[n] <> NIL
oFillColor := oFill:ForeColor
oFillColor:RGB:=afondo[1]
case n = 2 .and. afondo[n] <> NIL
oFillColor := oFill:BackColor
oFillColor:RGB:=afondo[2]
case n = 3 .and. afondo[n] <> NIL
oFill:Transparency:=afondo[3]
case n = 4 .and. afondo[n] <> NIL
oFill:TwoColorGradient( afondo[4], afondo[5] )
case n = 6 .and. afondo[n] <> NIL
oFill:Patterned( afondo[6] )
case n = 7 .and. afondo[n] <> NIL
oFill:PresetTextured( afondo[7] )
case n = 8 .and. afondo[n] <> NIL
oFill:UserTextured( afondo[8] )
endcase
next n
//Line de contorno
oLine := oCuadro:Line
for n = 1 to len(aLine)
do case
case n = 1
oLine:Weight:= aLine[1]
if aLine[1] = 0
oLine:Visible:= 0
endif
case n = 2
oLine:ForeColor:=aLine[2]
case n = 3
oLine:BackColor:=aLine[3]
case n = 4
oLine:Transparency:=aLine[4]
case n = 5
oLine:DashStyle:=aLine[5]
case n = 5
oLine:Style:=aLine[6]
endcase
next n
oCuadroText := oCuadro:TextFrame
oText := oCuadroText:TextRange
oFontC := oText:Font
*oFontC:Name :=oFont:cName
*oFontC:Size :=INT(oFont:nHeight)
*oFontC:Bold :=oFont:lBold
*oFontC:Color:=nclrtext
*oText:HighlightColorIndex:=nClrBack
oText:Text:=cText
oParagraph := oText:ParagraphFormat
oParagraph:Alignment:=nPad
if lvertadjust
nheightbox := 0
oCuadro:Height:=nheightbox
::oDocument:ComputeStatistics( 2,.t.)
lnocabe := oCuadroText:Overflowing
nheightbox := nheightbox + nHeighttext //+ OleGetProperty(oParagraph,'SpaceBefore')
do whil lnocabe = .t. .and. nheightbox <= nBottom - nTop
oCuadro:Height:=nheightbox
oText:Text:=cText
::oDocument:ComputeStatistics( 2,.t.)
lnocabe := oCuadroText:Overflowing
nheightbox := nheightbox + nHeighttext //+ OleGetProperty(oParagraph,'SpaceBefore')
enddo
else
::oDocument:ComputeStatistics( 2,.t.)
lnocabe := oCuadroText:Overflowing
nheightbox := nBottom
endif
lcorta := lnocabe
cText2 := cText
do whil lcorta .and. !empty(cText2)
cText2 := Dellastword(cText2)
oText:Text:= cText2
::oDocument:ComputeStatistics( 2,.t.)
lcorta := oCuadroText:Overflowing
enddo
::ctextoverflow := strtran(cText, cText2, '')
::loverflowing := lnocabe
release oParagraph, OLine, oFillColor, oFill, oFontC, oText,oCuadroText, oCuadro
if lvertadjust
if ::lsetcm
::nlastrow := (ntop + nheightbox)/28.35
else
::nlastrow := ntop + nheightbox
endif
else
if ::lsetcm
::nlastrow := nBottom/28.35
else
::nlastrow := nBottom
endif
endif
Return Nil
static function dellastword(cText)
Local sal := rtrim(cText)
do whil !empty(sal)
sal := substr(sal,1, len(sal)-1)
if substr(sal, len(sal), 1) = chr(32) .or. substr(sal, len(sal), 1) = chr(13)
exit
endif
enddo
return sal
METHOD Pages() CLASS TWord
Local oProperties,oPages
oProperties:=::oDocument:BuiltInDocumentProperties
oPages:=oProperties:Item(wdPropertyPages)
Return oPages:Value
METHOD NewPage() CLASS TWord
::GoBottom()
::oText:InsertBreak(wdPageBreak)
::oText:GotoNext(wdGoToPage)
::Write(chr(31)) //Es necesario para ponder vincular los cuadros de texto a una pagina determinada.
Return Nil
//Put elements on document
METHOD Say( nLin,nCol,cText,oFont, nSize, lBold, lShadow, nColor ) CLASS TWord
Local cFont := "Arial" //oFont:cFaceName
Default nLin to 0
Default nCol to 0
If nLin>0 .Or. nCol>0
::Goto(nLin,nCol)
Endif
::Write( cText, cFont, nSize, lBold, lShadow, nColor )
Return Nil
METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor ) CLASS TWord
Local oFont := ::oText:Font
oFont:Name :=cFont
oFont:Size :=nSize
oFont:Bold := lBold
oFont:ColorIndex:=nColor
oFont:Emboss :=lShadow
::oText:TypeText( cText )
oFont:Reset()
release oFont
Return nil
METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo, nrotacion ) CLASS TWord
::Box(nTop, nLeft, nBottom, nRight, {,,,,,,,cImage}, aLine, ntipo, nrotacion, .t.)
Return Nil
METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo, nrotation, lPicTextured ) CLASS TWord
Local oShapes,oShapBox, oFill, oFillColor, oLine, n
DEFAULT afondo To {}
DEFAULT aLine To {}
DEFAULT ntipo To 1
DEFAULT nrotation To 0
DEFAULT lPicTextured To .f.
::nLastRow := nBottom
if ::lsetcm
nTop := nTop*28.35
nLeft := nLeft*28.35
nBottom := nBottom*28.35
nRight := nRight*28.35
endif
nRight := nRight - nLeft
nBottom := nBottom - nTop
oShapes := ::oSelection:Shapes
oShapBox := oShapes:AddShape( ntipo,nLeft,nTop,nRight,nBottom )
oShapBox:RelativeHorizontalPosition:=1
oShapBox:RelativeVerticalPosition:=1
oFill := oShapBox:Fill
oShapBox:Rotation:=nrotation
For n = 1 to len(afondo)
do case
case n = 1 .and. afondo[n] <> NIL
oFillColor := oFill:ForeColor
oFillColor:RGB:=afondo[1]
case n = 2 .and. afondo[n] <> NIL
oFillColor := oFill:BackColor
oFillColor:RGB:=afondo[2]
case n = 3 .and. afondo[n] <> NIL
oFill:Transparency:=afondo[3]
case n = 4 .and. afondo[n] <> NIL
oFill:TwoColorGradient( afondo[4], afondo[5] )
case n = 6 .and. afondo[n] <> NIL
oFill:Patterned( afondo[6] )
case n = 7 .and. afondo[n] <> NIL
oFill:PresetTextured( afondo[7] )
case n = 8 .and. afondo[n] <> NIL
if lPicTextured = .t.
oFill:UserPicture( afondo[8] )
else
oFill:UserTextured( afondo[8] )
endif
endcase
Next
oLine := oShapBox:Line
For n = 1 to len(aLine)
do case
case n = 1
oLine:Weight:= aLine[1]
if aLine[1] = 0
oLine:Visible:=0
endif
case n = 2
oLine:ForeColor:=aLine[2]
case n = 3
oLine:BackColor:= aLine[3]
case n = 4
oLine:Transparency:= aLine[4]
case n = 5
oLine:DashStyle:= aLine[5]
case n = 5
oLine:Style:= aLine[6]
endcase
Next
release oShapes,oShapBox, oFill, oFillColor, oLine
Return Nil
//Find & replace_____________________________________________________ __________
METHOD Find( cText ) CLASS TWord
LOCAL oText, oFind
::Gotop()
oText :=::oSelection:Range()
oFind := oText:Find
oFind:Text :=cText
oFind:Forward :=.T.
oFind:Wrap :=INT(1)
oFind:Format :=.f.
oFind:MatchCase :=.f.
oFind:MatchWholeWord :=.t.
oFind:MatchWildcards :=.f.
oFind:MatchSoundsLike :=.f.
oFind:MatchAllWordForms :=.f.
oFind:Execute()
If oFind:Found
::oText:Startof(wdLine) //Pendiente
::oText:Moveend(wdLine)
Endif
release oFind,oText
Return oFind:Found
METHOD Replace( cOld, cNew ) CLASS TWord
LOCAL oText, oFind, oReplace
oText :=::oSelection:Range()
oFind := oText:Find
oFind:Text :=cOld
oFind:Forward :=.T.
oFind:Wrap :=INT(1)
oFind:Format :=.f.
oFind:MatchCase :=.f.
oFind:MatchWholeWord :=.t.
oFind:MatchWildcards :=.f.
oFind:MatchSoundsLike :=.f.
oFind:MatchAllWordForms :=.f.
oFind:Execute()
DO WHILE oFind:Found
oText:Text:=cNew
oFind:Execute()
Enddo
release oReplace,oFind,oText
Return Nil
//Selection of document parts_____________________________________________________
METHOD SelectAll() CLASS TWord
::oRange:= ::oDocument:Range(::oDocument:Content:Start,::oDocument:cont ent:End)
::oRange:Select()
Return Nil
METHOD UnSelect() CLASS TWord
::oRange:= ::oDocument:Range(0,0)
::oRange:Select()
Return Nil
METHOD SelCurrentLine() CLASS TWord
Local Start, end, oProperties
::oText:Startof(wdLine)
::oText:Moveend(wdLine)
Return Nil
METHOD SelCurrentPara() CLASS TWord
Local Start, end, oProperties
::oText:Startof(wdParagraph)
::oText:Moveend(wdParagraph)
Return Nil
METHOD ListOfFields(aDatasets, lShow) CLASS TWord
Local oForm, aFields:={}, nField, oField, oBrw, nAt:=0, x:=0, lOk:=.F.
Local cName:="", nItem:=0, nNumber:=0
Default lShow To .T.
CursorWait()
For nItem:=1 to Len(aDataSets)
cName:=aDataSets[nItem]:cName
cName:=If(aDataSets[nItem]:Cargo<>Nil,aDataSets[nItem]:Cargo,cName)
For nField:= 1 To Len(aDataSets[nItem]:aFields)
Aadd(aFields,{Upper(cName)+":"+Alltrim(aDataSets[nItem]:aFields[nField]:cName),;
ToString(aDataSets[nItem]:aFields[nField]:Value)})
Next
Next
CursorArrow()
If !lShow
Return aFields
Endif
DEFINE FORM oForm TITLE "List of Fields" OF GetActiveform() ;
SIZE 363, 427 BORDERSTYLE bsDIALOG
@ 25, 10 ARRAYBROWSE oBrw Size 343,300 Items aFields Headers {"Dbf","Field"} OF oForm
oBrw:lRecordSelector :=.F.
oBrw:nMarqueeStyle :=bmHIGHLROWRC
oBrw:nClrAltPane :=clLtGray
oBrw:OnDblClick :={|| (lOk := .T., nAt:=oBrw:nArrayAt, oForm:Close()) }
@ 364, 20 BUTTON CAPTION LT( XA_MSG_ACEPTAR ) SIZE 80, 25 OF oForm ;
ACTION (lOk := .T., nAt:=oBrw:aArrayData[oBrw:nArrayAt,Len(oBrw:aArrayData[1])], oForm:Close()) Default
@ 364, 250 BUTTON CAPTION LT( XA_MSG_IMPRIMIR ) SIZE 80, 25 OF oForm ;
ACTION PrnARRAY(aFields)
oBrw:lFilterBar:=.F.
oBrw:lAutoOrder:=.t.
ACTIVATE FORM oForm MODAL CENTER
Return aFields
METHOD ReplaceFields(aDatasets) CLASS TWord
Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
CursorWait()
For nField:= 1 to Len(aFields)
::Replace("{"+aFields[nField,1]+"}",Alltrim(ToString(aFields[nField,2])))
Next
CursorArrow()
Return aFields
METHOD ReplaceArrays(aDatasets,nColumnaInicial) CLASS TWord
Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
Local aDatabases:={}, nDB, nLine, nColumn, cTexto:=""
Default nColumnaInicial To 1
CursorWait()
FOR nDB := 1 TO Len( aDatasets )
cTexto:=""
For nLine:=1 to Len(aDatasets[nDB]:aData)
For nColumn:=If(nColumnaInicial>1,nColumnaInicial,1) to Len(aDatasets[nDB]:aData[nLine])
Do Case
Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="L"
cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] , "S","N")
Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="N"
cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] >0,;
Alltrim(ToString(aDatasets[nDB]:aData[nLine,nColumn]))," ")
OtherWise
cTexto:=cTexto+Chr(9)+Alltrim(ToString(aDatasets[nDB]:aData[ nLine,nColumn]))
EndCase
Next
cTexto:=cTexto+Chr(13)
Next
::Replace("{"+aDatasets[nDB]:Cargo+":Tabla}",cTexto)
NEXT
CursorArrow()
Return Nil
******* IMPRIMIR ARRAY
STATIC FUNCTION PrnARRAY(aItems,aHeads,cTitle,cText)
Local ofrmPreview, oFont, oPen, n := 100, nItem:=0, cHead:=""
Local aDatos:={}, aLen:={}, nL:=0, nC:=0, cTexto:="", lSalir:=.F., nNumpage:=0
DEFAULT aHeads To {}
DEFAULT cTitle To ""
DEFAULT cText To ""
CursorWait()
//Calcular Numero de columnas e inicializar longitudes de columna
aSize(aLen,If(ValType(aItems[1])="A",Len(aItems[1]),1))
aFill(aLen,0)
//Si no hay cabeceras crear un array de cabeceras a ""
If Len(aHeads)=0
aSize(aHeads,Len(aLen))
aFill(aHeads,"")
EndIf
//Calcular anchura máxima de cada columna
For nC:=1 to Len(aLen)
For nL:=1 to Len(aItems)
aLen[nC]:=Max(aLen[nC],Len(Alltrim(ToString(aItems[nL,nC]))) )
aLen[nC]:=Max(aLen[nC],Len(Alltrim(aHeads[nC])))
Next
Next
//Si hay cabeceras crear el literal de cabecera
If Len(aHeads)>0
For nC:=1 to Len(aLen)
cHead:=cHead+PadR(aHeads[nC],aLen[nC])+" "
Next
Endif
//Crear el literal de cada línea del Array y cargar a aDatos
For nL:=1 to Len(aItems)
cTexto:=""
For nC:=1 to Len(aLen)
Do Case
Case ValType(aItems[nL,nC])="C"
cTexto:=cTexto+PadR(aItems[nL,nC],aLen[nC])+" "
Case ValType(aItems[nL,nC])="N"
cTexto:=cTexto+Padl(Alltrim(Str(aItems[nL,nC])),aLen[nC])+" "
Case ValType(aItems[nL,nC])="D"
cTexto:=cTexto+PadR(Dtoc(aItems[nL,nC]),10)+" "
EndCase
Next
Aadd(aDatos,cTexto)
Next
//Comienza impresión
DEFINE FONT oFont NAME "COURIER NEW"
Printer:cJobTitle := cTitle
Printer:lPreview := .t.
Printer:StartDoc()
Printer:oCanvas:nMapMode := mmHIMETRICS
Do While !lSalir
Printer:StartPage()
WITH OBJECT Printer:oCanvas
:oFont := oFont
:oPen := oPen
:nMapMode := mmSIMULCHAR
:nTextAlignment:=taCENTER
:oFont:nSize := 14
:oFont:lBold := .T.
:oFont:lUnderline := .T.
:TextOut( 1, 1, cTitle,70, CLR_BLUE)
:nTextAlignment:=taLEFT
:oFont:nSize := 12
:TextOut( 2, 3, AllTrim(cHead),30, CLR_BLACK)
:oFont:lBold := .F.
:oFont:lUnderline := .F.
For n := 1 to :TextLines()-5
If ++nItem<=Len(aDatos)
:TextOut( 2, n+4, aDatos[nItem],30, CLR_BLACK)
Else
lSalir:=.T.
Exit
Endif
Next
:nTextAlignment:=taCENTER
:TextOut( 1, :TextLines(), "- "+Alltrim(ToString(++nNumpage))+" -",80, CLR_BLUE)
END WITH
Printer:EndPage()
Enddo
Printer:EndDoc()
Printer:Preview()
oFont:Destroy()
CursorArrow()
Return Nil
--
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9250
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Word desde Xailer.

Mensaje por ignacio »

Bingen,
Guauuuuuuu!! Súper completa.
Te animo a que la publiques en el Wiki, creo que puede ser muy interesante.
Gracias por tus contribuciones, son siempre excelentes.
Un saludo
--
Ignacio Ortiz de Zúñiga
[Soporte Xailer]
[Xailer support]
"Bingen Ugaldebere" <bingen@muninser.com> escribió en el mensaje
news:[email=48d87692@ozsrv2.ozlan.local...]48d87692@ozsrv2.ozlan.local...[/email]
> Perdón por el retraso en la lectura Xevi pero he tenido plaga de
> "bichos" por el disco duro, vamos una put.......
>
> Yo modifique y amplié la clase tWord original de Sebastian Almirón para
> Xailer y aunque veo que te han mandado ya alguna si quieres otra opción
> aquí va esta.
>
> SI necesitas alguna aclaración me lo dices.
>
> ::oWord := TWord():New()
>
> If !::oWord:lInstalled
> Alert( "ERROR! Word no esta instalado. [" + Ole2TxtError()+ "]" )
> Return Nil
> EndIf
>
>
> WITH OBJECT ::oWord
> :NewDoc( "Ficha "+::oDemandantes:Nombre+"
> "+::oDemandantes:Apellidos,;
> Application:cDirectory+"PlantillasFicha.Doc")
>
> :Replacefields({::oDemandantes})
>
> :ReplaceArrays({::oMemPermisosConducir,::oMemForm,::oMemForm Comp,::oMemIdiomas,::oMemExperiencia},3)
>
> :View()
> END
>
>
------------------------------------------------------------ --------------------
> /*
> * Proyecto: Microsoft Word Management Class via OLE
> * Fichero: TWord.prg
> * Autor: Bingen Ugaldebere - Mungia Informática
> * Based in a original class for FW 16bits from Sebastian Almirón
> * Fecha: 21/08/2007 - 10/09/2007
> */
>
> #include "Xailer.ch"
> #include "tWord.ch"
>
> CLASS TWord
>
> Data oWord
> Data cDocName
> Data OleDocs
> Data lInstalled Init .T.
> Data OleDocs
> Data oDocument
> Data oText
> Data oSelection
> Data oRange
> Data cDocName
> Data nLine,nCol, nPage
> Data nYoffset, nXoffset
> Data lStartpag
> Data lOverflowing
> Data nlastrow
> Data cTextOverflow
> Data lSetCm
>
> METHOD New()
> METHOD NewDoc( cDocName, cTemplate )
> METHOD View()
> METHOD Hide()
> METHOD OpenDoc( cDocName, lReadonly )
> METHOD Preview()
> METHOD SetLandScape()
> METHOD SetPortrait()
> METHOD Setpaper(nWidth, nHeight, lLandscape)
> METHOD CloseDoc(oDoc)
> METHOD End()
> METHOD CheckSpelling()
>
> METHOD GoBottom()
> METHOD Gotop()
> METHOD GoEnd()
> METHOD GoInit()
> METHOD GoUp(nLines)
> METHOD GoDown(nLines)
> METHOD Goto(nLin,nCol)
> METHOD GoRight(nChar)
> METHOD GoLeft(nChar)
> METHOD GotoPage(nPage)
> METHOD GotoHeader()
> METHOD GotoFooter()
> METHOD GotoDocument()
>
> METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo,
> nItem, nCopias, cPages)
> METHOD Protect(cPassword,nMode)
> METHOD UnProtect(cPassword)
> METHOD Save(cDocName)
> METHOD Say( nLin,nCol,cText,oFont,nSizeHorz,nClrText,nBkMode,nPad,
> nAltura, nClrIndex, lVertAdjust )
> METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor )
> METHOD SetCm()
> METHOD GetTextHeight( oFont )
> METHOD GetTextWidth(cText, oFont)
> METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext,
> nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation)
> METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo,
> nrotacion )
> METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo,
> nrotation, lPicTextured )
>
> METHOD FullView()
> METHOD Pages()
> METHOD Find( cText )
> METHOD Replace( cOld, cNew )
> METHOD ReplaceFields(aDatasets)
> Method ReplaceArrays(aDatasets,nColumnaInicial)
> METHOD ListOfFields(aDatasets,lShow)
> METHOD NewPage()
>
> METHOD SelectAll()
> METHOD SelCurrentLine()
> METHOD SelCurrentPara()
> METHOD UnSelect()
>
> METHOD Cut() INLINE ::oText:Cut()
> METHOD Copy() INLINE ::oText:Copy()
> METHOD Paste() INLINE ::oText:Paste()
>
> ENDCLASS
>
> METHOD NEW() CLASS TWord
>
> TRY
> ::oWord := GetActiveObject( "Word.Application" )
> CATCH
> TRY
> ::oWord := CreateObject( "Word.Application" )
> CATCH
> ::lInstalled := .F.
> END
> END
>
> Return Self
>
> //Document
> management__________________________________________________ ________
> METHOD NewDoc( cDocName, cTemplate ) CLASS TWord
> DEFAULT cDocName TO "Documento1"
> DEFAULT cTemplate TO ""
>
> ::oWord:Documents:Add(cTemplate)
>
> ::OleDocs := ::oWord:Documents
> ::oDocument := ::oWord:ActiveDocument
> ::oText := ::oWord:Selection
> ::cDocName := cDocName
> ::nLine := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::lstartpag := .t.
> ::oSelection := ::oDocument
> ::oRange := ::oDocument:Range(1,1)
> ::lSetcm := .f.
> ::lOverflowing := .f.
> ::nlastrow := 0
> ::ctextoverflow := ''
>
> Return Nil
>
> METHOD OpenDoc( cDocName, lReadOnly )
> Local lOk := .t.
> Default lReadOnly To .F.
>
> ::OleDocs := ::oWord:Documents
> If File( cDocName )
> ::cDocName := cDocName
> ::oDocument := ::Oledocs:Open(::cDocName,,lReadOnly)
> if valtype(::oDocument) <> 'O'
> lOk := .f.
> else
> ::oText := ::oWord:Selection
> ::nLine := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::oSelection := ::oDocument
> ::oRange := ::oDocument:Range(1,1)
> ::lstartpag := .t.
> ::lsetcm := .f.
> ::lOverflowing := .f.
> ::nlastrow := 0
> ::ctextoverflow := ''
> Endif
> else
> MsgStop("Word File Not Found"+CRLF+CRLF+cDocName )
> lOk := .f.
> endif
>
> Return lOk
>
> METHOD Save(cDocName) CLASS TWord
> DEFAULT cDocName To ::cDocName
> ::oDocument:SaveAs( cDocName )
> Return Nil
>
> METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo,
> nItem, nCopias, cPages) CLASS TWord
> Local Csinpath, cPath
> DEFAULT lBackground To .f.
> DEFAULT lAppend To .f.
> DEFAULT nRange To 0
> DEFAULT cOutputFile To ''
> DEFAULT nFrom To ''
> DEFAULT nTo To ''
> DEFAULT nItem To 0
> DEFAULT nCopias To 1
> DEFAULT cPages To ''
>
> If !Empty(nFrom) .Or. !Empty(nTo)
> nRange := 3
> nFrom := Alltrim(Str(Int(nFrom)))
> nTo := Alltrim(Str(Int(nTo)))
> Endif
>
> If Empty(cOutputFile)
> ::oDocument:PrintOut(lbackground,lappend,int(nRange),'',nfro m, nto,
> nitem,ncopias, cpages )
> Else
> cPath := FilePath(cOutputFile)
> If !Empty(cPath) .and. cPath <>''
> ::OleWord:ChangeFileOpenDirectory(cPath)
> Endif
> cSinpath := FileFullName(cOutputFile)
> ::OleWord:PrintOut(lbackground,lappend,int(nRange),csinpath, nfrom,
> nto, nitem, ncopias, cpages )
> Endif
> Return Nil
>
> METHOD CloseDoc(oDoc,lSaveChanges) CLASS TWord
> DEFAULT oDoc To ::oDocument
> DEFAULT lSaveChanges To .F.
> oDoc:Close(If(lSaveChanges,0,-1)) // 0=Close without save changes -1=Close
> saving changes
> Return Nil
>
> METHOD End(lSaveChanges) CLASS TWord
> DEFAULT lSaveChanges To .F.
> ::OleDocs:Close(,lSaveChanges)
> ::oWord:Quit()
> ::oText := NIL
> ::oDocument := NIL
> ::OleDocs := NIL
> ::oWord := NIL
> Return nil
>
> //Presentation
> Management__________________________________________________ _____
> METHOD View(nView) CLASS TWord
> Default nView To 1
> ::oWord:Visible := .T.
> ::oWord:WindowState := 2
> ::oWord:WindowState := nView // 1=Maximize 2=Minimize 3=Normal
> Return Nil
>
> METHOD Hide() CLASS TWord
> ::oWord:Visible := .F.
> Return Nil
>
> METHOD FullView() CLASS TWord
> LOCAL oWindow, oView
>
> oWindow := ::oDocument:ActiveWindow
> oView := oWindow:View
> oView:FullScreen:=.T.
> ::View()
> release oView
> Return nil
>
> METHOD SetPortrait() CLASS TWord
> Local oPageSetup := ::oDocument:PageSetup
> oPageSetup:Orientation:=wdOrientPortrait
> release oPageSetup
> Return Nil
>
> METHOD SetLandScape() CLASS TWord
> Local oPageSetup := ::oDocument:PageSetup
> oPageSetup:Orientation:=wdOrientLandscape
> release oPageSetup
> Return Nil
>
> METHOD Setpaper(nWidth, nHeight, lLandscape) CLASS TWord
> Local oPage
> DEFAULT nWidth To 21
> DEFAULT nHeight To 29.7
> DEFAULT lLandscape To .F.
> oPage := ::oDocument:Pagesetup
>
> If lLandscape
> oPage:Orientation:=wdOrientLandscape
> Else
> oPage:Orientation:=wdOrientPortrait
> Endif
>
> oPage:PageWidth :=nWidth*28.35
> oPage:PageHeight :=nHeight*28.35
>
> release opage
>
> Return Nil
>
> METHOD Preview() CLASS TWord
> ::oWord:PrintPreview()
> ::oDocument:PrintPreview()
> ::View()
> Return nil
>
> //Positioning_______________________________________________ ___________________
> METHOD Gotop() CLASS TWord
> ::oText:HomeKey(wdStory,wdMove)
> Return nil
>
> METHOD GoBottom() CLASS TWord
> ::oText:EndKey(wdStory,wdMove)
> Return nil
>
> METHOD GoInit() CLASS TWord
> ::oText:HomeKey()
> Return nil
>
> METHOD GoEnd() CLASS TWord
> ::oText:EndKey()
> Return nil
>
> METHOD GoDown(nLines) CLASS TWord
> Default nLines To 1
> ::oText:MoveDown(wdLine,nLines,wdMove)
> Return nil
>
> METHOD GoUp(nLines) CLASS TWord
> Default nLines To 1
> ::oText:MoveUp(wdLine,nLines,wdMove)
> Return nil
>
> METHOD GoRight(nChar) CLASS TWord
> Default nChar To 1
> ::oText:MoveRight(wdCharacter,nChar,wdMove)
> Return nil
>
> METHOD GoLeft(nChar) CLASS TWord
> Default nChar To 1
> ::oText:MoveLeft(wdCharacter,nChar,wdMove)
> Return nil
>
> METHOD Goto(nLin,nCol) CLASS TWord
> Local n:=1, oProperties,oLines
> Default nCol to 1
>
> CursorWait()
> oProperties:=::oDocument:BuiltInDocumentProperties
> oLines:=oProperties:Item(wdPropertyLines)
>
> If oLines:Value>nLin
> ::Gotop()
> ::GoDown(nLin-1)
> Else
> For n=1 to nLin-oLines:Value
> ::oText:TypeText( Chr(13) )
> ::GoBottom()
> Next
> Endif
>
> ::GoInit()
> ::GoRight(nCol-1)
>
> CursorArrow()
> Return nil
>
> METHOD GotoPage(nPage) CLASS TWord
> Local n:=1
> Default nPage To 1
> ::GoTop()
> For n:=1 to nPage-1
> ::oText:GotoNext(wdGoToPage)
> Next
> Return Nil
>
> METHOD GotoHeader() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekCurrentPageHeader
> ::oSelection := ::oText:HeaderFooter
> release oWindow, oView
> Return Nil
>
> METHOD GotoFooter() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekCurrentPageFooter
> ::oSelection := ::oText:HeaderFooter
> release oWindow, oView
> Return Nil
>
> METHOD GotoDocument() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekMainDocument
> ::oSelection := ::oDocument
> release oWindow, oView
> Return Nil
>
>
>
> //Other features
> METHOD CheckSpelling() CLASS TWord
> ::oDocument:CheckSpelling()
> Return nil
>
> METHOD Protect(cPassword,nMode) CLASS TWord
> DEFAULT nMode To 3
> If cPassword=Nil
> Msginfo("ERROR: Imposible proteger Documento sin un paswword")
> Return .F.
> Endif
>
> ::oDocument:Protect( nMode, .F. , cPassword )
>
> Return .T.
>
> METHOD UnProtect(cPassword) CLASS TWord
> ::oDocument:UnProtect( cPassword )
> return nil
>
> METHOD SetCm() CLASS TWord
> ::lSetCm := .t.
> Return Nil
>
> METHOD GetTextHeight( oFont ) CLASS TWord
> Local nHeight
> If ::lsetcm
> nHeight := oFont:nHeight/28.35
> Else
> nHeight := oFont:nHeight
> Endif
> Return nHeight
>
>
> METHOD GetTextWidth(cText, oFont) CLASS TWord
> Local nWidth
> If oFont:nHeight > 0
> nWidth := (oFont:nHeight/1.6)*len(ctext)
> Else
> nWidth :=((oFont:nHeight*-1)/1.6)*len(ctext)
> Endif
> Return nWidth
>
> METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext,
> nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation) CLASS TWord
> local oShapes,oCuadro,oFill,oLine, oFontC, oText, oCuadroText, cText2,
> lCorta, oParagraph, oFillColor
> local nPad := 0, n, oWrap, nheighttext, lnocabe := .f., nheightbox:= 0
>
> DEFAULT nTop To 0
> DEFAULT nLeft To 0
> DEFAULT nBottom To 10
> DEFAULT nRight To 10
> DEFAULT cText To ' '
> DEFAULT oFont To TFont():New()
> DEFAULT nClrText To RGB(0,0,0)
> DEFAULT nJustify To 0
> DEFAULT afondo To {}
> DEFAULT aLine To {}
> DEFAULT lvertadjust To .f.
> DEFAULT nOrientation To 1
>
> nheighttext := oFont:nHeight
>
> If nOrientation > 3
> nOrientation := 1
> Endif
>
> do case
> case nJustify = 1
> nPad := 2
> case nJustify = 2
> nPad := 1
> case nJustify = 6
> nPad := 0
> endcase
>
> if ::lsetcm
> nTop := nTop*28.35
> nLeft := nLeft*28.35
> nBottom := nBottom*28.35
> nRight := nRight*28.35
> endif
>
>
> oShapes := ::oSelection:Shapes
> oCuadro := oShapes:AddTextbox(
> nOrientation,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBot tom-nTop) )
> oFill := oCuadro:Fill
>
> // OleSetProperty( oCuadro, 'RelativeHorizontalPosition',1)
> // OleSetProperty( oCuadro, 'RelativeVerticalPosition',1)
>
> //Fill
> for n = 1 to len(afondo)
> do case
> case n = 1 .and. afondo[n] <> NIL
> oFillColor := oFill:ForeColor
> oFillColor:RGB:=afondo[1]
> case n = 2 .and. afondo[n] <> NIL
> oFillColor := oFill:BackColor
> oFillColor:RGB:=afondo[2]
> case n = 3 .and. afondo[n] <> NIL
> oFill:Transparency:=afondo[3]
> case n = 4 .and. afondo[n] <> NIL
> oFill:TwoColorGradient( afondo[4], afondo[5] )
> case n = 6 .and. afondo[n] <> NIL
> oFill:Patterned( afondo[6] )
> case n = 7 .and. afondo[n] <> NIL
> oFill:PresetTextured( afondo[7] )
> case n = 8 .and. afondo[n] <> NIL
> oFill:UserTextured( afondo[8] )
> endcase
> next n
>
> //Line de contorno
> oLine := oCuadro:Line
>
> for n = 1 to len(aLine)
> do case
> case n = 1
> oLine:Weight:= aLine[1]
> if aLine[1] = 0
> oLine:Visible:= 0
> endif
> case n = 2
> oLine:ForeColor:=aLine[2]
> case n = 3
> oLine:BackColor:=aLine[3]
> case n = 4
> oLine:Transparency:=aLine[4]
> case n = 5
> oLine:DashStyle:=aLine[5]
> case n = 5
> oLine:Style:=aLine[6]
> endcase
> next n
>
>
> oCuadroText := oCuadro:TextFrame
> oText := oCuadroText:TextRange
> oFontC := oText:Font
>
> *oFontC:Name :=oFont:cName
> *oFontC:Size :=INT(oFont:nHeight)
> *oFontC:Bold :=oFont:lBold
> *oFontC:Color:=nclrtext
>
> *oText:HighlightColorIndex:=nClrBack
>
> oText:Text:=cText
>
> oParagraph := oText:ParagraphFormat
>
>
> oParagraph:Alignment:=nPad
>
>
> if lvertadjust
> nheightbox := 0
> oCuadro:Height:=nheightbox
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nheightbox + nHeighttext //+
> OleGetProperty(oParagraph,'SpaceBefore')
> do whil lnocabe = .t. .and. nheightbox <= nBottom - nTop
> oCuadro:Height:=nheightbox
> oText:Text:=cText
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nheightbox + nHeighttext //+
> OleGetProperty(oParagraph,'SpaceBefore')
> enddo
>
> else
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nBottom
> endif
>
> lcorta := lnocabe
> cText2 := cText
> do whil lcorta .and. !empty(cText2)
> cText2 := Dellastword(cText2)
> oText:Text:= cText2
> ::oDocument:ComputeStatistics( 2,.t.)
> lcorta := oCuadroText:Overflowing
> enddo
>
> ::ctextoverflow := strtran(cText, cText2, '')
> ::loverflowing := lnocabe
>
> release oParagraph, OLine, oFillColor, oFill, oFontC, oText,oCuadroText,
> oCuadro
>
> if lvertadjust
> if ::lsetcm
> ::nlastrow := (ntop + nheightbox)/28.35
> else
> ::nlastrow := ntop + nheightbox
> endif
> else
> if ::lsetcm
> ::nlastrow := nBottom/28.35
> else
> ::nlastrow := nBottom
> endif
> endif
>
> Return Nil
>
> static function dellastword(cText)
> Local sal := rtrim(cText)
> do whil !empty(sal)
> sal := substr(sal,1, len(sal)-1)
> if substr(sal, len(sal), 1) = chr(32) .or. substr(sal, len(sal), 1) =
> chr(13)
> exit
> endif
> enddo
> return sal
>
> METHOD Pages() CLASS TWord
> Local oProperties,oPages
>
> oProperties:=::oDocument:BuiltInDocumentProperties
> oPages:=oProperties:Item(wdPropertyPages)
>
> Return oPages:Value
>
> METHOD NewPage() CLASS TWord
> ::GoBottom()
> ::oText:InsertBreak(wdPageBreak)
> ::oText:GotoNext(wdGoToPage)
> ::Write(chr(31)) //Es necesario para ponder vincular los cuadros de
> texto a una pagina determinada.
> Return Nil
>
> //Put elements on document
> METHOD Say( nLin,nCol,cText,oFont, nSize, lBold, lShadow, nColor ) CLASS
> TWord
> Local cFont := "Arial" //oFont:cFaceName
> Default nLin to 0
> Default nCol to 0
>
> If nLin>0 .Or. nCol>0
> ::Goto(nLin,nCol)
> Endif
>
> ::Write( cText, cFont, nSize, lBold, lShadow, nColor )
> Return Nil
>
> METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor ) CLASS TWord
> Local oFont := ::oText:Font
>
> oFont:Name :=cFont
> oFont:Size :=nSize
> oFont:Bold := lBold
> oFont:ColorIndex:=nColor
> oFont:Emboss :=lShadow
>
> ::oText:TypeText( cText )
> oFont:Reset()
> release oFont
> Return nil
>
>
> METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo,
> nrotacion ) CLASS TWord
>
> ::Box(nTop, nLeft, nBottom, nRight, {,,,,,,,cImage}, aLine, ntipo,
> nrotacion, .t.)
>
> Return Nil
>
> METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo, nrotation,
> lPicTextured ) CLASS TWord
> Local oShapes,oShapBox, oFill, oFillColor, oLine, n
>
> DEFAULT afondo To {}
> DEFAULT aLine To {}
> DEFAULT ntipo To 1
> DEFAULT nrotation To 0
> DEFAULT lPicTextured To .f.
>
> ::nLastRow := nBottom
> if ::lsetcm
> nTop := nTop*28.35
> nLeft := nLeft*28.35
> nBottom := nBottom*28.35
> nRight := nRight*28.35
> endif
> nRight := nRight - nLeft
> nBottom := nBottom - nTop
>
> oShapes := ::oSelection:Shapes
>
> oShapBox := oShapes:AddShape( ntipo,nLeft,nTop,nRight,nBottom )
>
> oShapBox:RelativeHorizontalPosition:=1
> oShapBox:RelativeVerticalPosition:=1
>
> oFill := oShapBox:Fill
>
> oShapBox:Rotation:=nrotation
>
> For n = 1 to len(afondo)
> do case
> case n = 1 .and. afondo[n] <> NIL
> oFillColor := oFill:ForeColor
> oFillColor:RGB:=afondo[1]
> case n = 2 .and. afondo[n] <> NIL
> oFillColor := oFill:BackColor
> oFillColor:RGB:=afondo[2]
> case n = 3 .and. afondo[n] <> NIL
> oFill:Transparency:=afondo[3]
> case n = 4 .and. afondo[n] <> NIL
> oFill:TwoColorGradient( afondo[4], afondo[5] )
> case n = 6 .and. afondo[n] <> NIL
> oFill:Patterned( afondo[6] )
> case n = 7 .and. afondo[n] <> NIL
> oFill:PresetTextured( afondo[7] )
> case n = 8 .and. afondo[n] <> NIL
> if lPicTextured = .t.
> oFill:UserPicture( afondo[8] )
> else
> oFill:UserTextured( afondo[8] )
> endif
> endcase
> Next
>
> oLine := oShapBox:Line
>
> For n = 1 to len(aLine)
> do case
> case n = 1
> oLine:Weight:= aLine[1]
> if aLine[1] = 0
> oLine:Visible:=0
> endif
> case n = 2
> oLine:ForeColor:=aLine[2]
> case n = 3
> oLine:BackColor:= aLine[3]
> case n = 4
> oLine:Transparency:= aLine[4]
> case n = 5
> oLine:DashStyle:= aLine[5]
> case n = 5
> oLine:Style:= aLine[6]
> endcase
> Next
>
> release oShapes,oShapBox, oFill, oFillColor, oLine
>
> Return Nil
>
> //Find &
> replace_____________________________________________________ __________
> METHOD Find( cText ) CLASS TWord
> LOCAL oText, oFind
>
> ::Gotop()
> oText :=::oSelection:Range()
> oFind := oText:Find
>
> oFind:Text :=cText
> oFind:Forward :=.T.
> oFind:Wrap :=INT(1)
> oFind:Format :=.f.
> oFind:MatchCase :=.f.
> oFind:MatchWholeWord :=.t.
> oFind:MatchWildcards :=.f.
> oFind:MatchSoundsLike :=.f.
> oFind:MatchAllWordForms :=.f.
>
> oFind:Execute()
> If oFind:Found
> ::oText:Startof(wdLine) //Pendiente
> ::oText:Moveend(wdLine)
> Endif
>
> release oFind,oText
>
> Return oFind:Found
>
> METHOD Replace( cOld, cNew ) CLASS TWord
> LOCAL oText, oFind, oReplace
>
> oText :=::oSelection:Range()
> oFind := oText:Find
>
> oFind:Text :=cOld
> oFind:Forward :=.T.
> oFind:Wrap :=INT(1)
> oFind:Format :=.f.
> oFind:MatchCase :=.f.
> oFind:MatchWholeWord :=.t.
> oFind:MatchWildcards :=.f.
> oFind:MatchSoundsLike :=.f.
> oFind:MatchAllWordForms :=.f.
>
> oFind:Execute()
> DO WHILE oFind:Found
> oText:Text:=cNew
> oFind:Execute()
> Enddo
>
> release oReplace,oFind,oText
>
> Return Nil
>
>
> //Selection of document
> parts_____________________________________________________
> METHOD SelectAll() CLASS TWord
> ::oRange:=
> ::oDocument:Range(::oDocument:Content:Start,::oDocument:cont ent:End)
> ::oRange:Select()
> Return Nil
>
> METHOD UnSelect() CLASS TWord
> ::oRange:= ::oDocument:Range(0,0)
> ::oRange:Select()
> Return Nil
>
> METHOD SelCurrentLine() CLASS TWord
> Local Start, end, oProperties
> ::oText:Startof(wdLine)
> ::oText:Moveend(wdLine)
> Return Nil
>
> METHOD SelCurrentPara() CLASS TWord
> Local Start, end, oProperties
> ::oText:Startof(wdParagraph)
> ::oText:Moveend(wdParagraph)
> Return Nil
>
> METHOD ListOfFields(aDatasets, lShow) CLASS TWord
> Local oForm, aFields:={}, nField, oField, oBrw, nAt:=0, x:=0, lOk:=.F.
> Local cName:="", nItem:=0, nNumber:=0
>
> Default lShow To .T.
>
> CursorWait()
>
> For nItem:=1 to Len(aDataSets)
>
> cName:=aDataSets[nItem]:cName
> cName:=If(aDataSets[nItem]:Cargo<>Nil,aDataSets[nItem]:Cargo,cName)
>
> For nField:= 1 To Len(aDataSets[nItem]:aFields)
>
> Aadd(aFields,{Upper(cName)+":"+Alltrim(aDataSets[nItem]:aFields[nField]:cName),;
> ToString(aDataSets[nItem]:aFields[nField]:Value)})
> Next
>
> Next
>
> CursorArrow()
>
> If !lShow
> Return aFields
> Endif
>
> DEFINE FORM oForm TITLE "List of Fields" OF GetActiveform() ;
> SIZE 363, 427 BORDERSTYLE bsDIALOG
>
> @ 25, 10 ARRAYBROWSE oBrw Size 343,300 Items aFields Headers
> {"Dbf","Field"} OF oForm
>
> oBrw:lRecordSelector :=.F.
> oBrw:nMarqueeStyle :=bmHIGHLROWRC
> oBrw:nClrAltPane :=clLtGray
> oBrw:OnDblClick :={|| (lOk := .T., nAt:=oBrw:nArrayAt,
> oForm:Close()) }
>
> @ 364, 20 BUTTON CAPTION LT( XA_MSG_ACEPTAR ) SIZE 80, 25 OF oForm ;
> ACTION (lOk := .T.,
> nAt:=oBrw:aArrayData[oBrw:nArrayAt,Len(oBrw:aArrayData[1])],
> oForm:Close()) Default
>
>
> @ 364, 250 BUTTON CAPTION LT( XA_MSG_IMPRIMIR ) SIZE 80, 25 OF oForm
> ;
> ACTION PrnARRAY(aFields)
>
> oBrw:lFilterBar:=.F.
> oBrw:lAutoOrder:=.t.
>
> ACTIVATE FORM oForm MODAL CENTER
>
> Return aFields
>
> METHOD ReplaceFields(aDatasets) CLASS TWord
> Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
>
> CursorWait()
>
> For nField:= 1 to Len(aFields)
>
> ::Replace("{"+aFields[nField,1]+"}",Alltrim(ToString(aFields[nField,2])))
> Next
>
> CursorArrow()
>
> Return aFields
>
> METHOD ReplaceArrays(aDatasets,nColumnaInicial) CLASS TWord
> Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
> Local aDatabases:={}, nDB, nLine, nColumn, cTexto:=""
>
> Default nColumnaInicial To 1
>
> CursorWait()
> FOR nDB := 1 TO Len( aDatasets )
>
> cTexto:=""
> For nLine:=1 to Len(aDatasets[nDB]:aData)
> For nColumn:=If(nColumnaInicial>1,nColumnaInicial,1) to
> Len(aDatasets[nDB]:aData[nLine])
> Do Case
> Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="L"
>
> cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] , "S","N")
> Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="N"
>
> cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] >0,;
>
> Alltrim(ToString(aDatasets[nDB]:aData[nLine,nColumn]))," ")
> OtherWise
>
> cTexto:=cTexto+Chr(9)+Alltrim(ToString(aDatasets[nDB]:aData[ nLine,nColumn]))
> EndCase
> Next
> cTexto:=cTexto+Chr(13)
> Next
> ::Replace("{"+aDatasets[nDB]:Cargo+":Tabla}",cTexto)
>
> NEXT
> CursorArrow()
>
> Return Nil
>
>
> ******* IMPRIMIR ARRAY
> STATIC FUNCTION PrnARRAY(aItems,aHeads,cTitle,cText)
> Local ofrmPreview, oFont, oPen, n := 100, nItem:=0, cHead:=""
> Local aDatos:={}, aLen:={}, nL:=0, nC:=0, cTexto:="", lSalir:=.F.,
> nNumpage:=0
>
> DEFAULT aHeads To {}
> DEFAULT cTitle To ""
> DEFAULT cText To ""
>
> CursorWait()
>
> //Calcular Numero de columnas e inicializar longitudes de columna
> aSize(aLen,If(ValType(aItems[1])="A",Len(aItems[1]),1))
> aFill(aLen,0)
>
> //Si no hay cabeceras crear un array de cabeceras a ""
> If Len(aHeads)=0
> aSize(aHeads,Len(aLen))
> aFill(aHeads,"")
> EndIf
>
> //Calcular anchura máxima de cada columna
> For nC:=1 to Len(aLen)
> For nL:=1 to Len(aItems)
> aLen[nC]:=Max(aLen[nC],Len(Alltrim(ToString(aItems[nL,nC]))) )
> aLen[nC]:=Max(aLen[nC],Len(Alltrim(aHeads[nC])))
> Next
> Next
>
> //Si hay cabeceras crear el literal de cabecera
> If Len(aHeads)>0
> For nC:=1 to Len(aLen)
> cHead:=cHead+PadR(aHeads[nC],aLen[nC])+" "
> Next
> Endif
>
> //Crear el literal de cada línea del Array y cargar a aDatos
> For nL:=1 to Len(aItems)
> cTexto:=""
> For nC:=1 to Len(aLen)
> Do Case
> Case ValType(aItems[nL,nC])="C"
> cTexto:=cTexto+PadR(aItems[nL,nC],aLen[nC])+" "
> Case ValType(aItems[nL,nC])="N"
> cTexto:=cTexto+Padl(Alltrim(Str(aItems[nL,nC])),aLen[nC])+"
> "
> Case ValType(aItems[nL,nC])="D"
> cTexto:=cTexto+PadR(Dtoc(aItems[nL,nC]),10)+" "
> EndCase
> Next
> Aadd(aDatos,cTexto)
> Next
>
>
> //Comienza impresión
> DEFINE FONT oFont NAME "COURIER NEW"
>
> Printer:cJobTitle := cTitle
> Printer:lPreview := .t.
> Printer:StartDoc()
> Printer:oCanvas:nMapMode := mmHIMETRICS
>
> Do While !lSalir
> Printer:StartPage()
> WITH OBJECT Printer:oCanvas
> :oFont := oFont
> :oPen := oPen
>
> :nMapMode := mmSIMULCHAR
> :nTextAlignment:=taCENTER
> :oFont:nSize := 14
> :oFont:lBold := .T.
> :oFont:lUnderline := .T.
> :TextOut( 1, 1, cTitle,70, CLR_BLUE)
>
> :nTextAlignment:=taLEFT
> :oFont:nSize := 12
> :TextOut( 2, 3, AllTrim(cHead),30, CLR_BLACK)
>
> :oFont:lBold := .F.
> :oFont:lUnderline := .F.
>
> For n := 1 to :TextLines()-5
> If ++nItem<=Len(aDatos)
> :TextOut( 2, n+4, aDatos[nItem],30, CLR_BLACK)
> Else
> lSalir:=.T.
> Exit
> Endif
> Next
> :nTextAlignment:=taCENTER
> :TextOut( 1, :TextLines(), "-
> "+Alltrim(ToString(++nNumpage))+" -",80, CLR_BLUE)
>
> END WITH
> Printer:EndPage()
> Enddo
> Printer:EndDoc()
> Printer:Preview()
> oFont:Destroy()
>
> CursorArrow()
>
> Return Nil
>
>
>
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Xevi
Mensajes: 1706
Registrado: Jue Sep 08, 2005 12:58 pm

Word desde Xailer.

Mensaje por Xevi »

Bingen,
Este trozo...
TRY
::oWord := GetActiveObject( "Word.Application" )
CATCH
TRY
::oWord := CreateObject( "Word.Application" )
CATCH
::lInstalled := .F.
END
END
Creo que me da algun problema al abrir el documento SI Word ya está abierto
con otro documento, no visualiza el documento que quiero ver, no me trae
"delante" la ventana de Word y me deja Word abierto con el documento
anterior abierto.
Para Word... ¿no sería mejor solo informar de si existe Word... sin querer
hacer activa la ventana de word y forzar abrir otra ventana de Word???
digo...
TRY
::oWord := CreateObject( "Word.Application" )
CATCH
::lInstalled := .F.
END
Un Saludo,
Xevi.
"Bingen Ugaldebere" <bingen@muninser.com> escribió en el mensaje
news:[email=48d87692@ozsrv2.ozlan.local...]48d87692@ozsrv2.ozlan.local...[/email]
> Perdón por el retraso en la lectura Xevi pero he tenido plaga de
> "bichos" por el disco duro, vamos una put.......
>
> Yo modifique y amplié la clase tWord original de Sebastian Almirón para
> Xailer y aunque veo que te han mandado ya alguna si quieres otra opción
> aquí va esta.
>
> SI necesitas alguna aclaración me lo dices.
>
> ::oWord := TWord():New()
>
> If !::oWord:lInstalled
> Alert( "ERROR! Word no esta instalado. [" + Ole2TxtError()+ "]" )
> Return Nil
> EndIf
>
>
> WITH OBJECT ::oWord
> :NewDoc( "Ficha "+::oDemandantes:Nombre+"
> "+::oDemandantes:Apellidos,;
> Application:cDirectory+"PlantillasFicha.Doc")
>
> :Replacefields({::oDemandantes})
>
> :ReplaceArrays({::oMemPermisosConducir,::oMemForm,::oMemForm Comp,::oMemIdiomas,::oMemExperiencia},3)
>
> :View()
> END
>
>
------------------------------------------------------------ --------------------
> /*
> * Proyecto: Microsoft Word Management Class via OLE
> * Fichero: TWord.prg
> * Autor: Bingen Ugaldebere - Mungia Informática
> * Based in a original class for FW 16bits from Sebastian Almirón
> * Fecha: 21/08/2007 - 10/09/2007
> */
>
> #include "Xailer.ch"
> #include "tWord.ch"
>
> CLASS TWord
>
> Data oWord
> Data cDocName
> Data OleDocs
> Data lInstalled Init .T.
> Data OleDocs
> Data oDocument
> Data oText
> Data oSelection
> Data oRange
> Data cDocName
> Data nLine,nCol, nPage
> Data nYoffset, nXoffset
> Data lStartpag
> Data lOverflowing
> Data nlastrow
> Data cTextOverflow
> Data lSetCm
>
> METHOD New()
> METHOD NewDoc( cDocName, cTemplate )
> METHOD View()
> METHOD Hide()
> METHOD OpenDoc( cDocName, lReadonly )
> METHOD Preview()
> METHOD SetLandScape()
> METHOD SetPortrait()
> METHOD Setpaper(nWidth, nHeight, lLandscape)
> METHOD CloseDoc(oDoc)
> METHOD End()
> METHOD CheckSpelling()
>
> METHOD GoBottom()
> METHOD Gotop()
> METHOD GoEnd()
> METHOD GoInit()
> METHOD GoUp(nLines)
> METHOD GoDown(nLines)
> METHOD Goto(nLin,nCol)
> METHOD GoRight(nChar)
> METHOD GoLeft(nChar)
> METHOD GotoPage(nPage)
> METHOD GotoHeader()
> METHOD GotoFooter()
> METHOD GotoDocument()
>
> METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo,
> nItem, nCopias, cPages)
> METHOD Protect(cPassword,nMode)
> METHOD UnProtect(cPassword)
> METHOD Save(cDocName)
> METHOD Say( nLin,nCol,cText,oFont,nSizeHorz,nClrText,nBkMode,nPad,
> nAltura, nClrIndex, lVertAdjust )
> METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor )
> METHOD SetCm()
> METHOD GetTextHeight( oFont )
> METHOD GetTextWidth(cText, oFont)
> METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext,
> nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation)
> METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo,
> nrotacion )
> METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo,
> nrotation, lPicTextured )
>
> METHOD FullView()
> METHOD Pages()
> METHOD Find( cText )
> METHOD Replace( cOld, cNew )
> METHOD ReplaceFields(aDatasets)
> Method ReplaceArrays(aDatasets,nColumnaInicial)
> METHOD ListOfFields(aDatasets,lShow)
> METHOD NewPage()
>
> METHOD SelectAll()
> METHOD SelCurrentLine()
> METHOD SelCurrentPara()
> METHOD UnSelect()
>
> METHOD Cut() INLINE ::oText:Cut()
> METHOD Copy() INLINE ::oText:Copy()
> METHOD Paste() INLINE ::oText:Paste()
>
> ENDCLASS
>
> METHOD NEW() CLASS TWord
>
> TRY
> ::oWord := GetActiveObject( "Word.Application" )
> CATCH
> TRY
> ::oWord := CreateObject( "Word.Application" )
> CATCH
> ::lInstalled := .F.
> END
> END
>
> Return Self
>
> //Document
> management__________________________________________________ ________
> METHOD NewDoc( cDocName, cTemplate ) CLASS TWord
> DEFAULT cDocName TO "Documento1"
> DEFAULT cTemplate TO ""
>
> ::oWord:Documents:Add(cTemplate)
>
> ::OleDocs := ::oWord:Documents
> ::oDocument := ::oWord:ActiveDocument
> ::oText := ::oWord:Selection
> ::cDocName := cDocName
> ::nLine := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::lstartpag := .t.
> ::oSelection := ::oDocument
> ::oRange := ::oDocument:Range(1,1)
> ::lSetcm := .f.
> ::lOverflowing := .f.
> ::nlastrow := 0
> ::ctextoverflow := ''
>
> Return Nil
>
> METHOD OpenDoc( cDocName, lReadOnly )
> Local lOk := .t.
> Default lReadOnly To .F.
>
> ::OleDocs := ::oWord:Documents
> If File( cDocName )
> ::cDocName := cDocName
> ::oDocument := ::Oledocs:Open(::cDocName,,lReadOnly)
> if valtype(::oDocument) <> 'O'
> lOk := .f.
> else
> ::oText := ::oWord:Selection
> ::nLine := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::oSelection := ::oDocument
> ::oRange := ::oDocument:Range(1,1)
> ::lstartpag := .t.
> ::lsetcm := .f.
> ::lOverflowing := .f.
> ::nlastrow := 0
> ::ctextoverflow := ''
> Endif
> else
> MsgStop("Word File Not Found"+CRLF+CRLF+cDocName )
> lOk := .f.
> endif
>
> Return lOk
>
> METHOD Save(cDocName) CLASS TWord
> DEFAULT cDocName To ::cDocName
> ::oDocument:SaveAs( cDocName )
> Return Nil
>
> METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo,
> nItem, nCopias, cPages) CLASS TWord
> Local Csinpath, cPath
> DEFAULT lBackground To .f.
> DEFAULT lAppend To .f.
> DEFAULT nRange To 0
> DEFAULT cOutputFile To ''
> DEFAULT nFrom To ''
> DEFAULT nTo To ''
> DEFAULT nItem To 0
> DEFAULT nCopias To 1
> DEFAULT cPages To ''
>
> If !Empty(nFrom) .Or. !Empty(nTo)
> nRange := 3
> nFrom := Alltrim(Str(Int(nFrom)))
> nTo := Alltrim(Str(Int(nTo)))
> Endif
>
> If Empty(cOutputFile)
> ::oDocument:PrintOut(lbackground,lappend,int(nRange),'',nfro m, nto,
> nitem,ncopias, cpages )
> Else
> cPath := FilePath(cOutputFile)
> If !Empty(cPath) .and. cPath <>''
> ::OleWord:ChangeFileOpenDirectory(cPath)
> Endif
> cSinpath := FileFullName(cOutputFile)
> ::OleWord:PrintOut(lbackground,lappend,int(nRange),csinpath, nfrom,
> nto, nitem, ncopias, cpages )
> Endif
> Return Nil
>
> METHOD CloseDoc(oDoc,lSaveChanges) CLASS TWord
> DEFAULT oDoc To ::oDocument
> DEFAULT lSaveChanges To .F.
> oDoc:Close(If(lSaveChanges,0,-1)) // 0=Close without save changes -1=Close
> saving changes
> Return Nil
>
> METHOD End(lSaveChanges) CLASS TWord
> DEFAULT lSaveChanges To .F.
> ::OleDocs:Close(,lSaveChanges)
> ::oWord:Quit()
> ::oText := NIL
> ::oDocument := NIL
> ::OleDocs := NIL
> ::oWord := NIL
> Return nil
>
> //Presentation
> Management__________________________________________________ _____
> METHOD View(nView) CLASS TWord
> Default nView To 1
> ::oWord:Visible := .T.
> ::oWord:WindowState := 2
> ::oWord:WindowState := nView // 1=Maximize 2=Minimize 3=Normal
> Return Nil
>
> METHOD Hide() CLASS TWord
> ::oWord:Visible := .F.
> Return Nil
>
> METHOD FullView() CLASS TWord
> LOCAL oWindow, oView
>
> oWindow := ::oDocument:ActiveWindow
> oView := oWindow:View
> oView:FullScreen:=.T.
> ::View()
> release oView
> Return nil
>
> METHOD SetPortrait() CLASS TWord
> Local oPageSetup := ::oDocument:PageSetup
> oPageSetup:Orientation:=wdOrientPortrait
> release oPageSetup
> Return Nil
>
> METHOD SetLandScape() CLASS TWord
> Local oPageSetup := ::oDocument:PageSetup
> oPageSetup:Orientation:=wdOrientLandscape
> release oPageSetup
> Return Nil
>
> METHOD Setpaper(nWidth, nHeight, lLandscape) CLASS TWord
> Local oPage
> DEFAULT nWidth To 21
> DEFAULT nHeight To 29.7
> DEFAULT lLandscape To .F.
> oPage := ::oDocument:Pagesetup
>
> If lLandscape
> oPage:Orientation:=wdOrientLandscape
> Else
> oPage:Orientation:=wdOrientPortrait
> Endif
>
> oPage:PageWidth :=nWidth*28.35
> oPage:PageHeight :=nHeight*28.35
>
> release opage
>
> Return Nil
>
> METHOD Preview() CLASS TWord
> ::oWord:PrintPreview()
> ::oDocument:PrintPreview()
> ::View()
> Return nil
>
> //Positioning_______________________________________________ ___________________
> METHOD Gotop() CLASS TWord
> ::oText:HomeKey(wdStory,wdMove)
> Return nil
>
> METHOD GoBottom() CLASS TWord
> ::oText:EndKey(wdStory,wdMove)
> Return nil
>
> METHOD GoInit() CLASS TWord
> ::oText:HomeKey()
> Return nil
>
> METHOD GoEnd() CLASS TWord
> ::oText:EndKey()
> Return nil
>
> METHOD GoDown(nLines) CLASS TWord
> Default nLines To 1
> ::oText:MoveDown(wdLine,nLines,wdMove)
> Return nil
>
> METHOD GoUp(nLines) CLASS TWord
> Default nLines To 1
> ::oText:MoveUp(wdLine,nLines,wdMove)
> Return nil
>
> METHOD GoRight(nChar) CLASS TWord
> Default nChar To 1
> ::oText:MoveRight(wdCharacter,nChar,wdMove)
> Return nil
>
> METHOD GoLeft(nChar) CLASS TWord
> Default nChar To 1
> ::oText:MoveLeft(wdCharacter,nChar,wdMove)
> Return nil
>
> METHOD Goto(nLin,nCol) CLASS TWord
> Local n:=1, oProperties,oLines
> Default nCol to 1
>
> CursorWait()
> oProperties:=::oDocument:BuiltInDocumentProperties
> oLines:=oProperties:Item(wdPropertyLines)
>
> If oLines:Value>nLin
> ::Gotop()
> ::GoDown(nLin-1)
> Else
> For n=1 to nLin-oLines:Value
> ::oText:TypeText( Chr(13) )
> ::GoBottom()
> Next
> Endif
>
> ::GoInit()
> ::GoRight(nCol-1)
>
> CursorArrow()
> Return nil
>
> METHOD GotoPage(nPage) CLASS TWord
> Local n:=1
> Default nPage To 1
> ::GoTop()
> For n:=1 to nPage-1
> ::oText:GotoNext(wdGoToPage)
> Next
> Return Nil
>
> METHOD GotoHeader() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekCurrentPageHeader
> ::oSelection := ::oText:HeaderFooter
> release oWindow, oView
> Return Nil
>
> METHOD GotoFooter() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekCurrentPageFooter
> ::oSelection := ::oText:HeaderFooter
> release oWindow, oView
> Return Nil
>
> METHOD GotoDocument() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekMainDocument
> ::oSelection := ::oDocument
> release oWindow, oView
> Return Nil
>
>
>
> //Other features
> METHOD CheckSpelling() CLASS TWord
> ::oDocument:CheckSpelling()
> Return nil
>
> METHOD Protect(cPassword,nMode) CLASS TWord
> DEFAULT nMode To 3
> If cPassword=Nil
> Msginfo("ERROR: Imposible proteger Documento sin un paswword")
> Return .F.
> Endif
>
> ::oDocument:Protect( nMode, .F. , cPassword )
>
> Return .T.
>
> METHOD UnProtect(cPassword) CLASS TWord
> ::oDocument:UnProtect( cPassword )
> return nil
>
> METHOD SetCm() CLASS TWord
> ::lSetCm := .t.
> Return Nil
>
> METHOD GetTextHeight( oFont ) CLASS TWord
> Local nHeight
> If ::lsetcm
> nHeight := oFont:nHeight/28.35
> Else
> nHeight := oFont:nHeight
> Endif
> Return nHeight
>
>
> METHOD GetTextWidth(cText, oFont) CLASS TWord
> Local nWidth
> If oFont:nHeight > 0
> nWidth := (oFont:nHeight/1.6)*len(ctext)
> Else
> nWidth :=((oFont:nHeight*-1)/1.6)*len(ctext)
> Endif
> Return nWidth
>
> METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext,
> nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation) CLASS TWord
> local oShapes,oCuadro,oFill,oLine, oFontC, oText, oCuadroText, cText2,
> lCorta, oParagraph, oFillColor
> local nPad := 0, n, oWrap, nheighttext, lnocabe := .f., nheightbox:= 0
>
> DEFAULT nTop To 0
> DEFAULT nLeft To 0
> DEFAULT nBottom To 10
> DEFAULT nRight To 10
> DEFAULT cText To ' '
> DEFAULT oFont To TFont():New()
> DEFAULT nClrText To RGB(0,0,0)
> DEFAULT nJustify To 0
> DEFAULT afondo To {}
> DEFAULT aLine To {}
> DEFAULT lvertadjust To .f.
> DEFAULT nOrientation To 1
>
> nheighttext := oFont:nHeight
>
> If nOrientation > 3
> nOrientation := 1
> Endif
>
> do case
> case nJustify = 1
> nPad := 2
> case nJustify = 2
> nPad := 1
> case nJustify = 6
> nPad := 0
> endcase
>
> if ::lsetcm
> nTop := nTop*28.35
> nLeft := nLeft*28.35
> nBottom := nBottom*28.35
> nRight := nRight*28.35
> endif
>
>
> oShapes := ::oSelection:Shapes
> oCuadro := oShapes:AddTextbox(
> nOrientation,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBot tom-nTop) )
> oFill := oCuadro:Fill
>
> // OleSetProperty( oCuadro, 'RelativeHorizontalPosition',1)
> // OleSetProperty( oCuadro, 'RelativeVerticalPosition',1)
>
> //Fill
> for n = 1 to len(afondo)
> do case
> case n = 1 .and. afondo[n] <> NIL
> oFillColor := oFill:ForeColor
> oFillColor:RGB:=afondo[1]
> case n = 2 .and. afondo[n] <> NIL
> oFillColor := oFill:BackColor
> oFillColor:RGB:=afondo[2]
> case n = 3 .and. afondo[n] <> NIL
> oFill:Transparency:=afondo[3]
> case n = 4 .and. afondo[n] <> NIL
> oFill:TwoColorGradient( afondo[4], afondo[5] )
> case n = 6 .and. afondo[n] <> NIL
> oFill:Patterned( afondo[6] )
> case n = 7 .and. afondo[n] <> NIL
> oFill:PresetTextured( afondo[7] )
> case n = 8 .and. afondo[n] <> NIL
> oFill:UserTextured( afondo[8] )
> endcase
> next n
>
> //Line de contorno
> oLine := oCuadro:Line
>
> for n = 1 to len(aLine)
> do case
> case n = 1
> oLine:Weight:= aLine[1]
> if aLine[1] = 0
> oLine:Visible:= 0
> endif
> case n = 2
> oLine:ForeColor:=aLine[2]
> case n = 3
> oLine:BackColor:=aLine[3]
> case n = 4
> oLine:Transparency:=aLine[4]
> case n = 5
> oLine:DashStyle:=aLine[5]
> case n = 5
> oLine:Style:=aLine[6]
> endcase
> next n
>
>
> oCuadroText := oCuadro:TextFrame
> oText := oCuadroText:TextRange
> oFontC := oText:Font
>
> *oFontC:Name :=oFont:cName
> *oFontC:Size :=INT(oFont:nHeight)
> *oFontC:Bold :=oFont:lBold
> *oFontC:Color:=nclrtext
>
> *oText:HighlightColorIndex:=nClrBack
>
> oText:Text:=cText
>
> oParagraph := oText:ParagraphFormat
>
>
> oParagraph:Alignment:=nPad
>
>
> if lvertadjust
> nheightbox := 0
> oCuadro:Height:=nheightbox
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nheightbox + nHeighttext //+
> OleGetProperty(oParagraph,'SpaceBefore')
> do whil lnocabe = .t. .and. nheightbox <= nBottom - nTop
> oCuadro:Height:=nheightbox
> oText:Text:=cText
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nheightbox + nHeighttext //+
> OleGetProperty(oParagraph,'SpaceBefore')
> enddo
>
> else
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nBottom
> endif
>
> lcorta := lnocabe
> cText2 := cText
> do whil lcorta .and. !empty(cText2)
> cText2 := Dellastword(cText2)
> oText:Text:= cText2
> ::oDocument:ComputeStatistics( 2,.t.)
> lcorta := oCuadroText:Overflowing
> enddo
>
> ::ctextoverflow := strtran(cText, cText2, '')
> ::loverflowing := lnocabe
>
> release oParagraph, OLine, oFillColor, oFill, oFontC, oText,oCuadroText,
> oCuadro
>
> if lvertadjust
> if ::lsetcm
> ::nlastrow := (ntop + nheightbox)/28.35
> else
> ::nlastrow := ntop + nheightbox
> endif
> else
> if ::lsetcm
> ::nlastrow := nBottom/28.35
> else
> ::nlastrow := nBottom
> endif
> endif
>
> Return Nil
>
> static function dellastword(cText)
> Local sal := rtrim(cText)
> do whil !empty(sal)
> sal := substr(sal,1, len(sal)-1)
> if substr(sal, len(sal), 1) = chr(32) .or. substr(sal, len(sal), 1) =
> chr(13)
> exit
> endif
> enddo
> return sal
>
> METHOD Pages() CLASS TWord
> Local oProperties,oPages
>
> oProperties:=::oDocument:BuiltInDocumentProperties
> oPages:=oProperties:Item(wdPropertyPages)
>
> Return oPages:Value
>
> METHOD NewPage() CLASS TWord
> ::GoBottom()
> ::oText:InsertBreak(wdPageBreak)
> ::oText:GotoNext(wdGoToPage)
> ::Write(chr(31)) //Es necesario para ponder vincular los cuadros de
> texto a una pagina determinada.
> Return Nil
>
> //Put elements on document
> METHOD Say( nLin,nCol,cText,oFont, nSize, lBold, lShadow, nColor ) CLASS
> TWord
> Local cFont := "Arial" //oFont:cFaceName
> Default nLin to 0
> Default nCol to 0
>
> If nLin>0 .Or. nCol>0
> ::Goto(nLin,nCol)
> Endif
>
> ::Write( cText, cFont, nSize, lBold, lShadow, nColor )
> Return Nil
>
> METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor ) CLASS TWord
> Local oFont := ::oText:Font
>
> oFont:Name :=cFont
> oFont:Size :=nSize
> oFont:Bold := lBold
> oFont:ColorIndex:=nColor
> oFont:Emboss :=lShadow
>
> ::oText:TypeText( cText )
> oFont:Reset()
> release oFont
> Return nil
>
>
> METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo,
> nrotacion ) CLASS TWord
>
> ::Box(nTop, nLeft, nBottom, nRight, {,,,,,,,cImage}, aLine, ntipo,
> nrotacion, .t.)
>
> Return Nil
>
> METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo, nrotation,
> lPicTextured ) CLASS TWord
> Local oShapes,oShapBox, oFill, oFillColor, oLine, n
>
> DEFAULT afondo To {}
> DEFAULT aLine To {}
> DEFAULT ntipo To 1
> DEFAULT nrotation To 0
> DEFAULT lPicTextured To .f.
>
> ::nLastRow := nBottom
> if ::lsetcm
> nTop := nTop*28.35
> nLeft := nLeft*28.35
> nBottom := nBottom*28.35
> nRight := nRight*28.35
> endif
> nRight := nRight - nLeft
> nBottom := nBottom - nTop
>
> oShapes := ::oSelection:Shapes
>
> oShapBox := oShapes:AddShape( ntipo,nLeft,nTop,nRight,nBottom )
>
> oShapBox:RelativeHorizontalPosition:=1
> oShapBox:RelativeVerticalPosition:=1
>
> oFill := oShapBox:Fill
>
> oShapBox:Rotation:=nrotation
>
> For n = 1 to len(afondo)
> do case
> case n = 1 .and. afondo[n] <> NIL
> oFillColor := oFill:ForeColor
> oFillColor:RGB:=afondo[1]
> case n = 2 .and. afondo[n] <> NIL
> oFillColor := oFill:BackColor
> oFillColor:RGB:=afondo[2]
> case n = 3 .and. afondo[n] <> NIL
> oFill:Transparency:=afondo[3]
> case n = 4 .and. afondo[n] <> NIL
> oFill:TwoColorGradient( afondo[4], afondo[5] )
> case n = 6 .and. afondo[n] <> NIL
> oFill:Patterned( afondo[6] )
> case n = 7 .and. afondo[n] <> NIL
> oFill:PresetTextured( afondo[7] )
> case n = 8 .and. afondo[n] <> NIL
> if lPicTextured = .t.
> oFill:UserPicture( afondo[8] )
> else
> oFill:UserTextured( afondo[8] )
> endif
> endcase
> Next
>
> oLine := oShapBox:Line
>
> For n = 1 to len(aLine)
> do case
> case n = 1
> oLine:Weight:= aLine[1]
> if aLine[1] = 0
> oLine:Visible:=0
> endif
> case n = 2
> oLine:ForeColor:=aLine[2]
> case n = 3
> oLine:BackColor:= aLine[3]
> case n = 4
> oLine:Transparency:= aLine[4]
> case n = 5
> oLine:DashStyle:= aLine[5]
> case n = 5
> oLine:Style:= aLine[6]
> endcase
> Next
>
> release oShapes,oShapBox, oFill, oFillColor, oLine
>
> Return Nil
>
> //Find &
> replace_____________________________________________________ __________
> METHOD Find( cText ) CLASS TWord
> LOCAL oText, oFind
>
> ::Gotop()
> oText :=::oSelection:Range()
> oFind := oText:Find
>
> oFind:Text :=cText
> oFind:Forward :=.T.
> oFind:Wrap :=INT(1)
> oFind:Format :=.f.
> oFind:MatchCase :=.f.
> oFind:MatchWholeWord :=.t.
> oFind:MatchWildcards :=.f.
> oFind:MatchSoundsLike :=.f.
> oFind:MatchAllWordForms :=.f.
>
> oFind:Execute()
> If oFind:Found
> ::oText:Startof(wdLine) //Pendiente
> ::oText:Moveend(wdLine)
> Endif
>
> release oFind,oText
>
> Return oFind:Found
>
> METHOD Replace( cOld, cNew ) CLASS TWord
> LOCAL oText, oFind, oReplace
>
> oText :=::oSelection:Range()
> oFind := oText:Find
>
> oFind:Text :=cOld
> oFind:Forward :=.T.
> oFind:Wrap :=INT(1)
> oFind:Format :=.f.
> oFind:MatchCase :=.f.
> oFind:MatchWholeWord :=.t.
> oFind:MatchWildcards :=.f.
> oFind:MatchSoundsLike :=.f.
> oFind:MatchAllWordForms :=.f.
>
> oFind:Execute()
> DO WHILE oFind:Found
> oText:Text:=cNew
> oFind:Execute()
> Enddo
>
> release oReplace,oFind,oText
>
> Return Nil
>
>
> //Selection of document
> parts_____________________________________________________
> METHOD SelectAll() CLASS TWord
> ::oRange:=
> ::oDocument:Range(::oDocument:Content:Start,::oDocument:cont ent:End)
> ::oRange:Select()
> Return Nil
>
> METHOD UnSelect() CLASS TWord
> ::oRange:= ::oDocument:Range(0,0)
> ::oRange:Select()
> Return Nil
>
> METHOD SelCurrentLine() CLASS TWord
> Local Start, end, oProperties
> ::oText:Startof(wdLine)
> ::oText:Moveend(wdLine)
> Return Nil
>
> METHOD SelCurrentPara() CLASS TWord
> Local Start, end, oProperties
> ::oText:Startof(wdParagraph)
> ::oText:Moveend(wdParagraph)
> Return Nil
>
> METHOD ListOfFields(aDatasets, lShow) CLASS TWord
> Local oForm, aFields:={}, nField, oField, oBrw, nAt:=0, x:=0, lOk:=.F.
> Local cName:="", nItem:=0, nNumber:=0
>
> Default lShow To .T.
>
> CursorWait()
>
> For nItem:=1 to Len(aDataSets)
>
> cName:=aDataSets[nItem]:cName
> cName:=If(aDataSets[nItem]:Cargo<>Nil,aDataSets[nItem]:Cargo,cName)
>
> For nField:= 1 To Len(aDataSets[nItem]:aFields)
>
> Aadd(aFields,{Upper(cName)+":"+Alltrim(aDataSets[nItem]:aFields[nField]:cName),;
> ToString(aDataSets[nItem]:aFields[nField]:Value)})
> Next
>
> Next
>
> CursorArrow()
>
> If !lShow
> Return aFields
> Endif
>
> DEFINE FORM oForm TITLE "List of Fields" OF GetActiveform() ;
> SIZE 363, 427 BORDERSTYLE bsDIALOG
>
> @ 25, 10 ARRAYBROWSE oBrw Size 343,300 Items aFields Headers
> {"Dbf","Field"} OF oForm
>
> oBrw:lRecordSelector :=.F.
> oBrw:nMarqueeStyle :=bmHIGHLROWRC
> oBrw:nClrAltPane :=clLtGray
> oBrw:OnDblClick :={|| (lOk := .T., nAt:=oBrw:nArrayAt,
> oForm:Close()) }
>
> @ 364, 20 BUTTON CAPTION LT( XA_MSG_ACEPTAR ) SIZE 80, 25 OF oForm ;
> ACTION (lOk := .T.,
> nAt:=oBrw:aArrayData[oBrw:nArrayAt,Len(oBrw:aArrayData[1])],
> oForm:Close()) Default
>
>
> @ 364, 250 BUTTON CAPTION LT( XA_MSG_IMPRIMIR ) SIZE 80, 25 OF oForm
> ;
> ACTION PrnARRAY(aFields)
>
> oBrw:lFilterBar:=.F.
> oBrw:lAutoOrder:=.t.
>
> ACTIVATE FORM oForm MODAL CENTER
>
> Return aFields
>
> METHOD ReplaceFields(aDatasets) CLASS TWord
> Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
>
> CursorWait()
>
> For nField:= 1 to Len(aFields)
>
> ::Replace("{"+aFields[nField,1]+"}",Alltrim(ToString(aFields[nField,2])))
> Next
>
> CursorArrow()
>
> Return aFields
>
> METHOD ReplaceArrays(aDatasets,nColumnaInicial) CLASS TWord
> Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
> Local aDatabases:={}, nDB, nLine, nColumn, cTexto:=""
>
> Default nColumnaInicial To 1
>
> CursorWait()
> FOR nDB := 1 TO Len( aDatasets )
>
> cTexto:=""
> For nLine:=1 to Len(aDatasets[nDB]:aData)
> For nColumn:=If(nColumnaInicial>1,nColumnaInicial,1) to
> Len(aDatasets[nDB]:aData[nLine])
> Do Case
> Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="L"
>
> cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] , "S","N")
> Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="N"
>
> cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] >0,;
>
> Alltrim(ToString(aDatasets[nDB]:aData[nLine,nColumn]))," ")
> OtherWise
>
> cTexto:=cTexto+Chr(9)+Alltrim(ToString(aDatasets[nDB]:aData[ nLine,nColumn]))
> EndCase
> Next
> cTexto:=cTexto+Chr(13)
> Next
> ::Replace("{"+aDatasets[nDB]:Cargo+":Tabla}",cTexto)
>
> NEXT
> CursorArrow()
>
> Return Nil
>
>
> ******* IMPRIMIR ARRAY
> STATIC FUNCTION PrnARRAY(aItems,aHeads,cTitle,cText)
> Local ofrmPreview, oFont, oPen, n := 100, nItem:=0, cHead:=""
> Local aDatos:={}, aLen:={}, nL:=0, nC:=0, cTexto:="", lSalir:=.F.,
> nNumpage:=0
>
> DEFAULT aHeads To {}
> DEFAULT cTitle To ""
> DEFAULT cText To ""
>
> CursorWait()
>
> //Calcular Numero de columnas e inicializar longitudes de columna
> aSize(aLen,If(ValType(aItems[1])="A",Len(aItems[1]),1))
> aFill(aLen,0)
>
> //Si no hay cabeceras crear un array de cabeceras a ""
> If Len(aHeads)=0
> aSize(aHeads,Len(aLen))
> aFill(aHeads,"")
> EndIf
>
> //Calcular anchura máxima de cada columna
> For nC:=1 to Len(aLen)
> For nL:=1 to Len(aItems)
> aLen[nC]:=Max(aLen[nC],Len(Alltrim(ToString(aItems[nL,nC]))) )
> aLen[nC]:=Max(aLen[nC],Len(Alltrim(aHeads[nC])))
> Next
> Next
>
> //Si hay cabeceras crear el literal de cabecera
> If Len(aHeads)>0
> For nC:=1 to Len(aLen)
> cHead:=cHead+PadR(aHeads[nC],aLen[nC])+" "
> Next
> Endif
>
> //Crear el literal de cada línea del Array y cargar a aDatos
> For nL:=1 to Len(aItems)
> cTexto:=""
> For nC:=1 to Len(aLen)
> Do Case
> Case ValType(aItems[nL,nC])="C"
> cTexto:=cTexto+PadR(aItems[nL,nC],aLen[nC])+" "
> Case ValType(aItems[nL,nC])="N"
> cTexto:=cTexto+Padl(Alltrim(Str(aItems[nL,nC])),aLen[nC])+"
> "
> Case ValType(aItems[nL,nC])="D"
> cTexto:=cTexto+PadR(Dtoc(aItems[nL,nC]),10)+" "
> EndCase
> Next
> Aadd(aDatos,cTexto)
> Next
>
>
> //Comienza impresión
> DEFINE FONT oFont NAME "COURIER NEW"
>
> Printer:cJobTitle := cTitle
> Printer:lPreview := .t.
> Printer:StartDoc()
> Printer:oCanvas:nMapMode := mmHIMETRICS
>
> Do While !lSalir
> Printer:StartPage()
> WITH OBJECT Printer:oCanvas
> :oFont := oFont
> :oPen := oPen
>
> :nMapMode := mmSIMULCHAR
> :nTextAlignment:=taCENTER
> :oFont:nSize := 14
> :oFont:lBold := .T.
> :oFont:lUnderline := .T.
> :TextOut( 1, 1, cTitle,70, CLR_BLUE)
>
> :nTextAlignment:=taLEFT
> :oFont:nSize := 12
> :TextOut( 2, 3, AllTrim(cHead),30, CLR_BLACK)
>
> :oFont:lBold := .F.
> :oFont:lUnderline := .F.
>
> For n := 1 to :TextLines()-5
> If ++nItem<=Len(aDatos)
> :TextOut( 2, n+4, aDatos[nItem],30, CLR_BLACK)
> Else
> lSalir:=.T.
> Exit
> Endif
> Next
> :nTextAlignment:=taCENTER
> :TextOut( 1, :TextLines(), "-
> "+Alltrim(ToString(++nNumpage))+" -",80, CLR_BLUE)
>
> END WITH
> Printer:EndPage()
> Enddo
> Printer:EndDoc()
> Printer:Preview()
> oFont:Destroy()
>
> CursorArrow()
>
> Return Nil
>
>
>
notengo
Mensajes: 417
Registrado: Vie Oct 12, 2007 1:29 pm

Word desde Xailer.

Mensaje por notengo »

Vikthor,
¡ Bienvenido !
> ¿ Aquí­ no me van a censurar ?
Apuesto a que no :-)
Saludos,
José Lalí­n
Vikthor
Mensajes: 18
Registrado: Jue Nov 16, 2006 4:31 pm

Word desde Xailer.

Mensaje por Vikthor »

Xavi :
con la clase puedes preguntar por el estado de Word.
::oWord := TWord():New()
If !::oWord:lInstalled
Alert( "ERROR! Word no esta instalado. [" + Ole2TxtError()+ "]" )
Return Nil
EndIf
IF ::oWord:IsVisible()
::oWord:Hide()
ENDIF
y acá sigue todo le demás :-)
Acá te dejo los métodos que yo uso
METHOD Hide() INLINE ::oWord:Visible := .F. // [ Vikthor ]
METHOD IsVisible() INLINE ::oWord:Visible // [ Vikthor ]
Saludos
Vikthor
http://listoelpollo.blogspot.com
"Xevi" <xevicomas_quitar_esto@gmail.com> escribió en el mensaje de noticias
news:[email=48d8a878@ozsrv2.ozlan.local...]48d8a878@ozsrv2.ozlan.local...[/email]
> Bingen,
>
> Este trozo...
> TRY
> ::oWord := GetActiveObject( "Word.Application" )
> CATCH
> TRY
> ::oWord := CreateObject( "Word.Application" )
> CATCH
> ::lInstalled := .F.
> END
> END
>
> Creo que me da algun problema al abrir el documento SI Word ya está
> abierto con otro documento, no visualiza el documento que quiero ver, no
> me trae "delante" la ventana de Word y me deja Word abierto con el
> documento anterior abierto.
>
> Para Word... ¿no serí­a mejor solo informar de si existe Word... sin querer
> hacer activa la ventana de word y forzar abrir otra ventana de Word???
> digo...
>
> TRY
> ::oWord := CreateObject( "Word.Application" )
> CATCH
> ::lInstalled := .F.
> END
>
>
> Un Saludo,
> Xevi.
>
>
> "Bingen Ugaldebere" <bingen@muninser.com> escribió en el mensaje
> news:[email=48d87692@ozsrv2.ozlan.local...]48d87692@ozsrv2.ozlan.local...[/email]
>> Perdón por el retraso en la lectura Xevi pero he tenido plaga de
>> "bichos" por el disco duro, vamos una put.......
>>
>> Yo modifique y amplié la clase tWord original de Sebastian Almirón para
>> Xailer y aunque veo que te han mandado ya alguna si quieres otra opción
>> aquí­ va esta.
>>
>> SI necesitas alguna aclaración me lo dices.
>>
>> ::oWord := TWord():New()
>>
>> If !::oWord:lInstalled
>> Alert( "ERROR! Word no esta instalado. [" + Ole2TxtError()+ "]" )
>> Return Nil
>> EndIf
>>
>>
>> WITH OBJECT ::oWord
>> :NewDoc( "Ficha "+::oDemandantes:Nombre+"
>> "+::oDemandantes:Apellidos,;
>> Application:cDirectory+"PlantillasFicha.Doc")
>>
>> :Replacefields({::oDemandantes})
>>
>> :ReplaceArrays({::oMemPermisosConducir,::oMemForm,::oMemForm Comp,::oMemIdiomas,::oMemExperiencia},3)
>>
>> :View()
>> END
>>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> /*
>> * Proyecto: Microsoft Word Management Class via OLE
>> * Fichero: TWord.prg
>> * Autor: Bingen Ugaldebere - Mungia Informática
>> * Based in a original class for FW 16bits from Sebastian Almirón
>> * Fecha: 21/08/2007 - 10/09/2007
>> */
>>
>> #include "Xailer.ch"
>> #include "tWord.ch"
>>
>> CLASS TWord
>>
>> Data oWord
>> Data cDocName
>> Data OleDocs
>> Data lInstalled Init .T.
>> Data OleDocs
>> Data oDocument
>> Data oText
>> Data oSelection
>> Data oRange
>> Data cDocName
>> Data nLine,nCol, nPage
>> Data nYoffset, nXoffset
>> Data lStartpag
>> Data lOverflowing
>> Data nlastrow
>> Data cTextOverflow
>> Data lSetCm
>>
>> METHOD New()
>> METHOD NewDoc( cDocName, cTemplate )
>> METHOD View()
>> METHOD Hide()
>> METHOD OpenDoc( cDocName, lReadonly )
>> METHOD Preview()
>> METHOD SetLandScape()
>> METHOD SetPortrait()
>> METHOD Setpaper(nWidth, nHeight, lLandscape)
>> METHOD CloseDoc(oDoc)
>> METHOD End()
>> METHOD CheckSpelling()
>>
>> METHOD GoBottom()
>> METHOD Gotop()
>> METHOD GoEnd()
>> METHOD GoInit()
>> METHOD GoUp(nLines)
>> METHOD GoDown(nLines)
>> METHOD Goto(nLin,nCol)
>> METHOD GoRight(nChar)
>> METHOD GoLeft(nChar)
>> METHOD GotoPage(nPage)
>> METHOD GotoHeader()
>> METHOD GotoFooter()
>> METHOD GotoDocument()
>>
>> METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo,
>> nItem, nCopias, cPages)
>> METHOD Protect(cPassword,nMode)
>> METHOD UnProtect(cPassword)
>> METHOD Save(cDocName)
>> METHOD Say( nLin,nCol,cText,oFont,nSizeHorz,nClrText,nBkMode,nPad,
>> nAltura, nClrIndex, lVertAdjust )
>> METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor )
>> METHOD SetCm()
>> METHOD GetTextHeight( oFont )
>> METHOD GetTextWidth(cText, oFont)
>> METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext,
>> nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation)
>> METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo,
>> nrotacion )
>> METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo,
>> nrotation, lPicTextured )
>>
>> METHOD FullView()
>> METHOD Pages()
>> METHOD Find( cText )
>> METHOD Replace( cOld, cNew )
>> METHOD ReplaceFields(aDatasets)
>> Method ReplaceArrays(aDatasets,nColumnaInicial)
>> METHOD ListOfFields(aDatasets,lShow)
>> METHOD NewPage()
>>
>> METHOD SelectAll()
>> METHOD SelCurrentLine()
>> METHOD SelCurrentPara()
>> METHOD UnSelect()
>>
>> METHOD Cut() INLINE ::oText:Cut()
>> METHOD Copy() INLINE ::oText:Copy()
>> METHOD Paste() INLINE ::oText:Paste()
>>
>> ENDCLASS
>>
>> METHOD NEW() CLASS TWord
>>
>> TRY
>> ::oWord := GetActiveObject( "Word.Application" )
>> CATCH
>> TRY
>> ::oWord := CreateObject( "Word.Application" )
>> CATCH
>> ::lInstalled := .F.
>> END
>> END
>>
>> Return Self
>>
>> //Document
>> management__________________________________________________ ________
>> METHOD NewDoc( cDocName, cTemplate ) CLASS TWord
>> DEFAULT cDocName TO "Documento1"
>> DEFAULT cTemplate TO ""
>>
>> ::oWord:Documents:Add(cTemplate)
>>
>> ::OleDocs := ::oWord:Documents
>> ::oDocument := ::oWord:ActiveDocument
>> ::oText := ::oWord:Selection
>> ::cDocName := cDocName
>> ::nLine := 0
>> ::nCol := 0
>> ::nPage := 0
>> ::nYoffset := 0
>> ::nXoffset := 0
>> ::lstartpag := .t.
>> ::oSelection := ::oDocument
>> ::oRange := ::oDocument:Range(1,1)
>> ::lSetcm := .f.
>> ::lOverflowing := .f.
>> ::nlastrow := 0
>> ::ctextoverflow := ''
>>
>> Return Nil
>>
>> METHOD OpenDoc( cDocName, lReadOnly )
>> Local lOk := .t.
>> Default lReadOnly To .F.
>>
>> ::OleDocs := ::oWord:Documents
>> If File( cDocName )
>> ::cDocName := cDocName
>> ::oDocument := ::Oledocs:Open(::cDocName,,lReadOnly)
>> if valtype(::oDocument) <> 'O'
>> lOk := .f.
>> else
>> ::oText := ::oWord:Selection
>> ::nLine := 0
>> ::nCol := 0
>> ::nPage := 0
>> ::nYoffset := 0
>> ::nXoffset := 0
>> ::oSelection := ::oDocument
>> ::oRange := ::oDocument:Range(1,1)
>> ::lstartpag := .t.
>> ::lsetcm := .f.
>> ::lOverflowing := .f.
>> ::nlastrow := 0
>> ::ctextoverflow := ''
>> Endif
>> else
>> MsgStop("Word File Not Found"+CRLF+CRLF+cDocName )
>> lOk := .f.
>> endif
>>
>> Return lOk
>>
>> METHOD Save(cDocName) CLASS TWord
>> DEFAULT cDocName To ::cDocName
>> ::oDocument:SaveAs( cDocName )
>> Return Nil
>>
>> METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo,
>> nItem, nCopias, cPages) CLASS TWord
>> Local Csinpath, cPath
>> DEFAULT lBackground To .f.
>> DEFAULT lAppend To .f.
>> DEFAULT nRange To 0
>> DEFAULT cOutputFile To ''
>> DEFAULT nFrom To ''
>> DEFAULT nTo To ''
>> DEFAULT nItem To 0
>> DEFAULT nCopias To 1
>> DEFAULT cPages To ''
>>
>> If !Empty(nFrom) .Or. !Empty(nTo)
>> nRange := 3
>> nFrom := Alltrim(Str(Int(nFrom)))
>> nTo := Alltrim(Str(Int(nTo)))
>> Endif
>>
>> If Empty(cOutputFile)
>> ::oDocument:PrintOut(lbackground,lappend,int(nRange),'',nfro m, nto,
>> nitem,ncopias, cpages )
>> Else
>> cPath := FilePath(cOutputFile)
>> If !Empty(cPath) .and. cPath <>''
>> ::OleWord:ChangeFileOpenDirectory(cPath)
>> Endif
>> cSinpath := FileFullName(cOutputFile)
>> ::OleWord:PrintOut(lbackground,lappend,int(nRange),csinpath, nfrom,
>> nto, nitem, ncopias, cpages )
>> Endif
>> Return Nil
>>
>> METHOD CloseDoc(oDoc,lSaveChanges) CLASS TWord
>> DEFAULT oDoc To ::oDocument
>> DEFAULT lSaveChanges To .F.
>> oDoc:Close(If(lSaveChanges,0,-1)) // 0=Close without save
>> changes -1=Close saving changes
>> Return Nil
>>
>> METHOD End(lSaveChanges) CLASS TWord
>> DEFAULT lSaveChanges To .F.
>> ::OleDocs:Close(,lSaveChanges)
>> ::oWord:Quit()
>> ::oText := NIL
>> ::oDocument := NIL
>> ::OleDocs := NIL
>> ::oWord := NIL
>> Return nil
>>
>> //Presentation
>> Management__________________________________________________ _____
>> METHOD View(nView) CLASS TWord
>> Default nView To 1
>> ::oWord:Visible := .T.
>> ::oWord:WindowState := 2
>> ::oWord:WindowState := nView // 1=Maximize 2=Minimize 3=Normal
>> Return Nil
>>
>> METHOD Hide() CLASS TWord
>> ::oWord:Visible := .F.
>> Return Nil
>>
>> METHOD FullView() CLASS TWord
>> LOCAL oWindow, oView
>>
>> oWindow := ::oDocument:ActiveWindow
>> oView := oWindow:View
>> oView:FullScreen:=.T.
>> ::View()
>> release oView
>> Return nil
>>
>> METHOD SetPortrait() CLASS TWord
>> Local oPageSetup := ::oDocument:PageSetup
>> oPageSetup:Orientation:=wdOrientPortrait
>> release oPageSetup
>> Return Nil
>>
>> METHOD SetLandScape() CLASS TWord
>> Local oPageSetup := ::oDocument:PageSetup
>> oPageSetup:Orientation:=wdOrientLandscape
>> release oPageSetup
>> Return Nil
>>
>> METHOD Setpaper(nWidth, nHeight, lLandscape) CLASS TWord
>> Local oPage
>> DEFAULT nWidth To 21
>> DEFAULT nHeight To 29.7
>> DEFAULT lLandscape To .F.
>> oPage := ::oDocument:Pagesetup
>>
>> If lLandscape
>> oPage:Orientation:=wdOrientLandscape
>> Else
>> oPage:Orientation:=wdOrientPortrait
>> Endif
>>
>> oPage:PageWidth :=nWidth*28.35
>> oPage:PageHeight :=nHeight*28.35
>>
>> release opage
>>
>> Return Nil
>>
>> METHOD Preview() CLASS TWord
>> ::oWord:PrintPreview()
>> ::oDocument:PrintPreview()
>> ::View()
>> Return nil
>>
>> //Positioning_______________________________________________ ___________________
>> METHOD Gotop() CLASS TWord
>> ::oText:HomeKey(wdStory,wdMove)
>> Return nil
>>
>> METHOD GoBottom() CLASS TWord
>> ::oText:EndKey(wdStory,wdMove)
>> Return nil
>>
>> METHOD GoInit() CLASS TWord
>> ::oText:HomeKey()
>> Return nil
>>
>> METHOD GoEnd() CLASS TWord
>> ::oText:EndKey()
>> Return nil
>>
>> METHOD GoDown(nLines) CLASS TWord
>> Default nLines To 1
>> ::oText:MoveDown(wdLine,nLines,wdMove)
>> Return nil
>>
>> METHOD GoUp(nLines) CLASS TWord
>> Default nLines To 1
>> ::oText:MoveUp(wdLine,nLines,wdMove)
>> Return nil
>>
>> METHOD GoRight(nChar) CLASS TWord
>> Default nChar To 1
>> ::oText:MoveRight(wdCharacter,nChar,wdMove)
>> Return nil
>>
>> METHOD GoLeft(nChar) CLASS TWord
>> Default nChar To 1
>> ::oText:MoveLeft(wdCharacter,nChar,wdMove)
>> Return nil
>>
>> METHOD Goto(nLin,nCol) CLASS TWord
>> Local n:=1, oProperties,oLines
>> Default nCol to 1
>>
>> CursorWait()
>> oProperties:=::oDocument:BuiltInDocumentProperties
>> oLines:=oProperties:Item(wdPropertyLines)
>>
>> If oLines:Value>nLin
>> ::Gotop()
>> ::GoDown(nLin-1)
>> Else
>> For n=1 to nLin-oLines:Value
>> ::oText:TypeText( Chr(13) )
>> ::GoBottom()
>> Next
>> Endif
>>
>> ::GoInit()
>> ::GoRight(nCol-1)
>>
>> CursorArrow()
>> Return nil
>>
>> METHOD GotoPage(nPage) CLASS TWord
>> Local n:=1
>> Default nPage To 1
>> ::GoTop()
>> For n:=1 to nPage-1
>> ::oText:GotoNext(wdGoToPage)
>> Next
>> Return Nil
>>
>> METHOD GotoHeader() CLASS TWord
>> Local oWindow := ::oDocument:ActiveWindow
>> local oView := oWindow:View
>> oView:SeekView:=wdSeekCurrentPageHeader
>> ::oSelection := ::oText:HeaderFooter
>> release oWindow, oView
>> Return Nil
>>
>> METHOD GotoFooter() CLASS TWord
>> Local oWindow := ::oDocument:ActiveWindow
>> local oView := oWindow:View
>> oView:SeekView:=wdSeekCurrentPageFooter
>> ::oSelection := ::oText:HeaderFooter
>> release oWindow, oView
>> Return Nil
>>
>> METHOD GotoDocument() CLASS TWord
>> Local oWindow := ::oDocument:ActiveWindow
>> local oView := oWindow:View
>> oView:SeekView:=wdSeekMainDocument
>> ::oSelection := ::oDocument
>> release oWindow, oView
>> Return Nil
>>
>>
>>
>> //Other features
>> METHOD CheckSpelling() CLASS TWord
>> ::oDocument:CheckSpelling()
>> Return nil
>>
>> METHOD Protect(cPassword,nMode) CLASS TWord
>> DEFAULT nMode To 3
>> If cPassword=Nil
>> Msginfo("ERROR: Imposible proteger Documento sin un paswword")
>> Return .F.
>> Endif
>>
>> ::oDocument:Protect( nMode, .F. , cPassword )
>>
>> Return .T.
>>
>> METHOD UnProtect(cPassword) CLASS TWord
>> ::oDocument:UnProtect( cPassword )
>> return nil
>>
>> METHOD SetCm() CLASS TWord
>> ::lSetCm := .t.
>> Return Nil
>>
>> METHOD GetTextHeight( oFont ) CLASS TWord
>> Local nHeight
>> If ::lsetcm
>> nHeight := oFont:nHeight/28.35
>> Else
>> nHeight := oFont:nHeight
>> Endif
>> Return nHeight
>>
>>
>> METHOD GetTextWidth(cText, oFont) CLASS TWord
>> Local nWidth
>> If oFont:nHeight > 0
>> nWidth := (oFont:nHeight/1.6)*len(ctext)
>> Else
>> nWidth :=((oFont:nHeight*-1)/1.6)*len(ctext)
>> Endif
>> Return nWidth
>>
>> METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext,
>> nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation) CLASS TWord
>> local oShapes,oCuadro,oFill,oLine, oFontC, oText, oCuadroText, cText2,
>> lCorta, oParagraph, oFillColor
>> local nPad := 0, n, oWrap, nheighttext, lnocabe := .f., nheightbox:= 0
>>
>> DEFAULT nTop To 0
>> DEFAULT nLeft To 0
>> DEFAULT nBottom To 10
>> DEFAULT nRight To 10
>> DEFAULT cText To ' '
>> DEFAULT oFont To TFont():New()
>> DEFAULT nClrText To RGB(0,0,0)
>> DEFAULT nJustify To 0
>> DEFAULT afondo To {}
>> DEFAULT aLine To {}
>> DEFAULT lvertadjust To .f.
>> DEFAULT nOrientation To 1
>>
>> nheighttext := oFont:nHeight
>>
>> If nOrientation > 3
>> nOrientation := 1
>> Endif
>>
>> do case
>> case nJustify = 1
>> nPad := 2
>> case nJustify = 2
>> nPad := 1
>> case nJustify = 6
>> nPad := 0
>> endcase
>>
>> if ::lsetcm
>> nTop := nTop*28.35
>> nLeft := nLeft*28.35
>> nBottom := nBottom*28.35
>> nRight := nRight*28.35
>> endif
>>
>>
>> oShapes := ::oSelection:Shapes
>> oCuadro := oShapes:AddTextbox(
>> nOrientation,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBot tom-nTop) )
>> oFill := oCuadro:Fill
>>
>> // OleSetProperty( oCuadro, 'RelativeHorizontalPosition',1)
>> // OleSetProperty( oCuadro, 'RelativeVerticalPosition',1)
>>
>> //Fill
>> for n = 1 to len(afondo)
>> do case
>> case n = 1 .and. afondo[n] <> NIL
>> oFillColor := oFill:ForeColor
>> oFillColor:RGB:=afondo[1]
>> case n = 2 .and. afondo[n] <> NIL
>> oFillColor := oFill:BackColor
>> oFillColor:RGB:=afondo[2]
>> case n = 3 .and. afondo[n] <> NIL
>> oFill:Transparency:=afondo[3]
>> case n = 4 .and. afondo[n] <> NIL
>> oFill:TwoColorGradient( afondo[4], afondo[5] )
>> case n = 6 .and. afondo[n] <> NIL
>> oFill:Patterned( afondo[6] )
>> case n = 7 .and. afondo[n] <> NIL
>> oFill:PresetTextured( afondo[7] )
>> case n = 8 .and. afondo[n] <> NIL
>> oFill:UserTextured( afondo[8] )
>> endcase
>> next n
>>
>> //Line de contorno
>> oLine := oCuadro:Line
>>
>> for n = 1 to len(aLine)
>> do case
>> case n = 1
>> oLine:Weight:= aLine[1]
>> if aLine[1] = 0
>> oLine:Visible:= 0
>> endif
>> case n = 2
>> oLine:ForeColor:=aLine[2]
>> case n = 3
>> oLine:BackColor:=aLine[3]
>> case n = 4
>> oLine:Transparency:=aLine[4]
>> case n = 5
>> oLine:DashStyle:=aLine[5]
>> case n = 5
>> oLine:Style:=aLine[6]
>> endcase
>> next n
>>
>>
>> oCuadroText := oCuadro:TextFrame
>> oText := oCuadroText:TextRange
>> oFontC := oText:Font
>>
>> *oFontC:Name :=oFont:cName
>> *oFontC:Size :=INT(oFont:nHeight)
>> *oFontC:Bold :=oFont:lBold
>> *oFontC:Color:=nclrtext
>>
>> *oText:HighlightColorIndex:=nClrBack
>>
>> oText:Text:=cText
>>
>> oParagraph := oText:ParagraphFormat
>>
>>
>> oParagraph:Alignment:=nPad
>>
>>
>> if lvertadjust
>> nheightbox := 0
>> oCuadro:Height:=nheightbox
>> ::oDocument:ComputeStatistics( 2,.t.)
>> lnocabe := oCuadroText:Overflowing
>> nheightbox := nheightbox + nHeighttext //+
>> OleGetProperty(oParagraph,'SpaceBefore')
>> do whil lnocabe = .t. .and. nheightbox <= nBottom - nTop
>> oCuadro:Height:=nheightbox
>> oText:Text:=cText
>> ::oDocument:ComputeStatistics( 2,.t.)
>> lnocabe := oCuadroText:Overflowing
>> nheightbox := nheightbox + nHeighttext //+
>> OleGetProperty(oParagraph,'SpaceBefore')
>> enddo
>>
>> else
>> ::oDocument:ComputeStatistics( 2,.t.)
>> lnocabe := oCuadroText:Overflowing
>> nheightbox := nBottom
>> endif
>>
>> lcorta := lnocabe
>> cText2 := cText
>> do whil lcorta .and. !empty(cText2)
>> cText2 := Dellastword(cText2)
>> oText:Text:= cText2
>> ::oDocument:ComputeStatistics( 2,.t.)
>> lcorta := oCuadroText:Overflowing
>> enddo
>>
>> ::ctextoverflow := strtran(cText, cText2, '')
>> ::loverflowing := lnocabe
>>
>> release oParagraph, OLine, oFillColor, oFill, oFontC,
>> oText,oCuadroText, oCuadro
>>
>> if lvertadjust
>> if ::lsetcm
>> ::nlastrow := (ntop + nheightbox)/28.35
>> else
>> ::nlastrow := ntop + nheightbox
>> endif
>> else
>> if ::lsetcm
>> ::nlastrow := nBottom/28.35
>> else
>> ::nlastrow := nBottom
>> endif
>> endif
>>
>> Return Nil
>>
>> static function dellastword(cText)
>> Local sal := rtrim(cText)
>> do whil !empty(sal)
>> sal := substr(sal,1, len(sal)-1)
>> if substr(sal, len(sal), 1) = chr(32) .or. substr(sal, len(sal), 1) =
>> chr(13)
>> exit
>> endif
>> enddo
>> return sal
>>
>> METHOD Pages() CLASS TWord
>> Local oProperties,oPages
>>
>> oProperties:=::oDocument:BuiltInDocumentProperties
>> oPages:=oProperties:Item(wdPropertyPages)
>>
>> Return oPages:Value
>>
>> METHOD NewPage() CLASS TWord
>> ::GoBottom()
>> ::oText:InsertBreak(wdPageBreak)
>> ::oText:GotoNext(wdGoToPage)
>> ::Write(chr(31)) //Es necesario para ponder vincular los cuadros de
>> texto a una pagina determinada.
>> Return Nil
>>
>> //Put elements on document
>> METHOD Say( nLin,nCol,cText,oFont, nSize, lBold, lShadow, nColor ) CLASS
>> TWord
>> Local cFont := "Arial" //oFont:cFaceName
>> Default nLin to 0
>> Default nCol to 0
>>
>> If nLin>0 .Or. nCol>0
>> ::Goto(nLin,nCol)
>> Endif
>>
>> ::Write( cText, cFont, nSize, lBold, lShadow, nColor )
>> Return Nil
>>
>> METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor ) CLASS TWord
>> Local oFont := ::oText:Font
>>
>> oFont:Name :=cFont
>> oFont:Size :=nSize
>> oFont:Bold := lBold
>> oFont:ColorIndex:=nColor
>> oFont:Emboss :=lShadow
>>
>> ::oText:TypeText( cText )
>> oFont:Reset()
>> release oFont
>> Return nil
>>
>>
>> METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo,
>> nrotacion ) CLASS TWord
>>
>> ::Box(nTop, nLeft, nBottom, nRight, {,,,,,,,cImage}, aLine, ntipo,
>> nrotacion, .t.)
>>
>> Return Nil
>>
>> METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo,
>> nrotation, lPicTextured ) CLASS TWord
>> Local oShapes,oShapBox, oFill, oFillColor, oLine, n
>>
>> DEFAULT afondo To {}
>> DEFAULT aLine To {}
>> DEFAULT ntipo To 1
>> DEFAULT nrotation To 0
>> DEFAULT lPicTextured To .f.
>>
>> ::nLastRow := nBottom
>> if ::lsetcm
>> nTop := nTop*28.35
>> nLeft := nLeft*28.35
>> nBottom := nBottom*28.35
>> nRight := nRight*28.35
>> endif
>> nRight := nRight - nLeft
>> nBottom := nBottom - nTop
>>
>> oShapes := ::oSelection:Shapes
>>
>> oShapBox := oShapes:AddShape( ntipo,nLeft,nTop,nRight,nBottom )
>>
>> oShapBox:RelativeHorizontalPosition:=1
>> oShapBox:RelativeVerticalPosition:=1
>>
>> oFill := oShapBox:Fill
>>
>> oShapBox:Rotation:=nrotation
>>
>> For n = 1 to len(afondo)
>> do case
>> case n = 1 .and. afondo[n] <> NIL
>> oFillColor := oFill:ForeColor
>> oFillColor:RGB:=afondo[1]
>> case n = 2 .and. afondo[n] <> NIL
>> oFillColor := oFill:BackColor
>> oFillColor:RGB:=afondo[2]
>> case n = 3 .and. afondo[n] <> NIL
>> oFill:Transparency:=afondo[3]
>> case n = 4 .and. afondo[n] <> NIL
>> oFill:TwoColorGradient( afondo[4], afondo[5] )
>> case n = 6 .and. afondo[n] <> NIL
>> oFill:Patterned( afondo[6] )
>> case n = 7 .and. afondo[n] <> NIL
>> oFill:PresetTextured( afondo[7] )
>> case n = 8 .and. afondo[n] <> NIL
>> if lPicTextured = .t.
>> oFill:UserPicture( afondo[8] )
>> else
>> oFill:UserTextured( afondo[8] )
>> endif
>> endcase
>> Next
>>
>> oLine := oShapBox:Line
>>
>> For n = 1 to len(aLine)
>> do case
>> case n = 1
>> oLine:Weight:= aLine[1]
>> if aLine[1] = 0
>> oLine:Visible:=0
>> endif
>> case n = 2
>> oLine:ForeColor:=aLine[2]
>> case n = 3
>> oLine:BackColor:= aLine[3]
>> case n = 4
>> oLine:Transparency:= aLine[4]
>> case n = 5
>> oLine:DashStyle:= aLine[5]
>> case n = 5
>> oLine:Style:= aLine[6]
>> endcase
>> Next
>>
>> release oShapes,oShapBox, oFill, oFillColor, oLine
>>
>> Return Nil
>>
>> //Find &
>> replace_____________________________________________________ __________
>> METHOD Find( cText ) CLASS TWord
>> LOCAL oText, oFind
>>
>> ::Gotop()
>> oText :=::oSelection:Range()
>> oFind := oText:Find
>>
>> oFind:Text :=cText
>> oFind:Forward :=.T.
>> oFind:Wrap :=INT(1)
>> oFind:Format :=.f.
>> oFind:MatchCase :=.f.
>> oFind:MatchWholeWord :=.t.
>> oFind:MatchWildcards :=.f.
>> oFind:MatchSoundsLike :=.f.
>> oFind:MatchAllWordForms :=.f.
>>
>> oFind:Execute()
>> If oFind:Found
>> ::oText:Startof(wdLine) //Pendiente
>> ::oText:Moveend(wdLine)
>> Endif
>>
>> release oFind,oText
>>
>> Return oFind:Found
>>
>> METHOD Replace( cOld, cNew ) CLASS TWord
>> LOCAL oText, oFind, oReplace
>>
>> oText :=::oSelection:Range()
>> oFind := oText:Find
>>
>> oFind:Text :=cOld
>> oFind:Forward :=.T.
>> oFind:Wrap :=INT(1)
>> oFind:Format :=.f.
>> oFind:MatchCase :=.f.
>> oFind:MatchWholeWord :=.t.
>> oFind:MatchWildcards :=.f.
>> oFind:MatchSoundsLike :=.f.
>> oFind:MatchAllWordForms :=.f.
>>
>> oFind:Execute()
>> DO WHILE oFind:Found
>> oText:Text:=cNew
>> oFind:Execute()
>> Enddo
>>
>> release oReplace,oFind,oText
>>
>> Return Nil
>>
>>
>> //Selection of document
>> parts_____________________________________________________
>> METHOD SelectAll() CLASS TWord
>> ::oRange:=
>> ::oDocument:Range(::oDocument:Content:Start,::oDocument:cont ent:End)
>> ::oRange:Select()
>> Return Nil
>>
>> METHOD UnSelect() CLASS TWord
>> ::oRange:= ::oDocument:Range(0,0)
>> ::oRange:Select()
>> Return Nil
>>
>> METHOD SelCurrentLine() CLASS TWord
>> Local Start, end, oProperties
>> ::oText:Startof(wdLine)
>> ::oText:Moveend(wdLine)
>> Return Nil
>>
>> METHOD SelCurrentPara() CLASS TWord
>> Local Start, end, oProperties
>> ::oText:Startof(wdParagraph)
>> ::oText:Moveend(wdParagraph)
>> Return Nil
>>
>> METHOD ListOfFields(aDatasets, lShow) CLASS TWord
>> Local oForm, aFields:={}, nField, oField, oBrw, nAt:=0, x:=0, lOk:=.F.
>> Local cName:="", nItem:=0, nNumber:=0
>>
>> Default lShow To .T.
>>
>> CursorWait()
>>
>> For nItem:=1 to Len(aDataSets)
>>
>> cName:=aDataSets[nItem]:cName
>> cName:=If(aDataSets[nItem]:Cargo<>Nil,aDataSets[nItem]:Cargo,cName)
>>
>> For nField:= 1 To Len(aDataSets[nItem]:aFields)
>>
>> Aadd(aFields,{Upper(cName)+":"+Alltrim(aDataSets[nItem]:aFields[nField]:cName),;
>> ToString(aDataSets[nItem]:aFields[nField]:Value)})
>> Next
>>
>> Next
>>
>> CursorArrow()
>>
>> If !lShow
>> Return aFields
>> Endif
>>
>> DEFINE FORM oForm TITLE "List of Fields" OF GetActiveform() ;
>> SIZE 363, 427 BORDERSTYLE bsDIALOG
>>
>> @ 25, 10 ARRAYBROWSE oBrw Size 343,300 Items aFields Headers
>> {"Dbf","Field"} OF oForm
>>
>> oBrw:lRecordSelector :=.F.
>> oBrw:nMarqueeStyle :=bmHIGHLROWRC
>> oBrw:nClrAltPane :=clLtGray
>> oBrw:OnDblClick :={|| (lOk := .T., nAt:=oBrw:nArrayAt,
>> oForm:Close()) }
>>
>> @ 364, 20 BUTTON CAPTION LT( XA_MSG_ACEPTAR ) SIZE 80, 25 OF oForm
>> ;
>> ACTION (lOk := .T.,
>> nAt:=oBrw:aArrayData[oBrw:nArrayAt,Len(oBrw:aArrayData[1])],
>> oForm:Close()) Default
>>
>>
>> @ 364, 250 BUTTON CAPTION LT( XA_MSG_IMPRIMIR ) SIZE 80, 25 OF oForm
>> ;
>> ACTION PrnARRAY(aFields)
>>
>> oBrw:lFilterBar:=.F.
>> oBrw:lAutoOrder:=.t.
>>
>> ACTIVATE FORM oForm MODAL CENTER
>>
>> Return aFields
>>
>> METHOD ReplaceFields(aDatasets) CLASS TWord
>> Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
>>
>> CursorWait()
>>
>> For nField:= 1 to Len(aFields)
>>
>> ::Replace("{"+aFields[nField,1]+"}",Alltrim(ToString(aFields[nField,2])))
>> Next
>>
>> CursorArrow()
>>
>> Return aFields
>>
>> METHOD ReplaceArrays(aDatasets,nColumnaInicial) CLASS TWord
>> Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
>> Local aDatabases:={}, nDB, nLine, nColumn, cTexto:=""
>>
>> Default nColumnaInicial To 1
>>
>> CursorWait()
>> FOR nDB := 1 TO Len( aDatasets )
>>
>> cTexto:=""
>> For nLine:=1 to Len(aDatasets[nDB]:aData)
>> For nColumn:=If(nColumnaInicial>1,nColumnaInicial,1) to
>> Len(aDatasets[nDB]:aData[nLine])
>> Do Case
>> Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="L"
>>
>> cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] , "S","N")
>> Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="N"
>>
>> cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] >0,;
>>
>> Alltrim(ToString(aDatasets[nDB]:aData[nLine,nColumn]))," ")
>> OtherWise
>>
>> cTexto:=cTexto+Chr(9)+Alltrim(ToString(aDatasets[nDB]:aData[ nLine,nColumn]))
>> EndCase
>> Next
>> cTexto:=cTexto+Chr(13)
>> Next
>> ::Replace("{"+aDatasets[nDB]:Cargo+":Tabla}",cTexto)
>>
>> NEXT
>> CursorArrow()
>>
>> Return Nil
>>
>>
>> ******* IMPRIMIR ARRAY
>> STATIC FUNCTION PrnARRAY(aItems,aHeads,cTitle,cText)
>> Local ofrmPreview, oFont, oPen, n := 100, nItem:=0, cHead:=""
>> Local aDatos:={}, aLen:={}, nL:=0, nC:=0, cTexto:="", lSalir:=.F.,
>> nNumpage:=0
>>
>> DEFAULT aHeads To {}
>> DEFAULT cTitle To ""
>> DEFAULT cText To ""
>>
>> CursorWait()
>>
>> //Calcular Numero de columnas e inicializar longitudes de columna
>> aSize(aLen,If(ValType(aItems[1])="A",Len(aItems[1]),1))
>> aFill(aLen,0)
>>
>> //Si no hay cabeceras crear un array de cabeceras a ""
>> If Len(aHeads)=0
>> aSize(aHeads,Len(aLen))
>> aFill(aHeads,"")
>> EndIf
>>
>> //Calcular anchura máxima de cada columna
>> For nC:=1 to Len(aLen)
>> For nL:=1 to Len(aItems)
>> aLen[nC]:=Max(aLen[nC],Len(Alltrim(ToString(aItems[nL,nC]))) )
>> aLen[nC]:=Max(aLen[nC],Len(Alltrim(aHeads[nC])))
>> Next
>> Next
>>
>> //Si hay cabeceras crear el literal de cabecera
>> If Len(aHeads)>0
>> For nC:=1 to Len(aLen)
>> cHead:=cHead+PadR(aHeads[nC],aLen[nC])+" "
>> Next
>> Endif
>>
>> //Crear el literal de cada lí­nea del Array y cargar a aDatos
>> For nL:=1 to Len(aItems)
>> cTexto:=""
>> For nC:=1 to Len(aLen)
>> Do Case
>> Case ValType(aItems[nL,nC])="C"
>> cTexto:=cTexto+PadR(aItems[nL,nC],aLen[nC])+" "
>> Case ValType(aItems[nL,nC])="N"
>> cTexto:=cTexto+Padl(Alltrim(Str(aItems[nL,nC])),aLen[nC])+"
>> "
>> Case ValType(aItems[nL,nC])="D"
>> cTexto:=cTexto+PadR(Dtoc(aItems[nL,nC]),10)+" "
>> EndCase
>> Next
>> Aadd(aDatos,cTexto)
>> Next
>>
>>
>> //Comienza impresión
>> DEFINE FONT oFont NAME "COURIER NEW"
>>
>> Printer:cJobTitle := cTitle
>> Printer:lPreview := .t.
>> Printer:StartDoc()
>> Printer:oCanvas:nMapMode := mmHIMETRICS
>>
>> Do While !lSalir
>> Printer:StartPage()
>> WITH OBJECT Printer:oCanvas
>> :oFont := oFont
>> :oPen := oPen
>>
>> :nMapMode := mmSIMULCHAR
>> :nTextAlignment:=taCENTER
>> :oFont:nSize := 14
>> :oFont:lBold := .T.
>> :oFont:lUnderline := .T.
>> :TextOut( 1, 1, cTitle,70, CLR_BLUE)
>>
>> :nTextAlignment:=taLEFT
>> :oFont:nSize := 12
>> :TextOut( 2, 3, AllTrim(cHead),30, CLR_BLACK)
>>
>> :oFont:lBold := .F.
>> :oFont:lUnderline := .F.
>>
>> For n := 1 to :TextLines()-5
>> If ++nItem<=Len(aDatos)
>> :TextOut( 2, n+4, aDatos[nItem],30, CLR_BLACK)
>> Else
>> lSalir:=.T.
>> Exit
>> Endif
>> Next
>> :nTextAlignment:=taCENTER
>> :TextOut( 1, :TextLines(), "-
>> "+Alltrim(ToString(++nNumpage))+" -",80, CLR_BLUE)
>>
>> END WITH
>> Printer:EndPage()
>> Enddo
>> Printer:EndDoc()
>> Printer:Preview()
>> oFont:Destroy()
>>
>> CursorArrow()
>>
>> Return Nil
>>
>>
>>
>
>
Bingen Ugaldebere
Mensajes: 1310
Registrado: Mié Sep 26, 2007 7:12 pm

Word desde Xailer.

Mensaje por Bingen Ugaldebere »

Gracias Ignacio
> Te animo a que la publiques en el Wiki, creo que puede ser muy interesante.
> Gracias por tus contribuciones, son siempre excelentes.
En cuanto tenga tiempo he de publicar esta y varias cosillas pero he de
documentarlas y preparar unos manualillos.
Por cierto no tengo ni idea de como publicar en la Wiki ya que lo que he
publicado hasta el momento ha sido en xailer.info
Lo intento y si no lo consigo ya os pregunto.
Salu2.
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9250
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Word desde Xailer.

Mensaje por ignacio »

Bingen,
Ok. Muchas gracias. Realmente publicar es un juego de niños.
Un saludo
--
Ignacio Ortiz de Zúñiga
[Soporte Xailer]
[Xailer support]
"Bingen Ugaldebere" <bingen@muninser.com> escribió en el mensaje
news:48dbeb8a$[email=1@ozsrv2.ozlan.local...]1@ozsrv2.ozlan.local...[/email]
> Gracias Ignacio
>> Te animo a que la publiques en el Wiki, creo que puede ser muy
>> interesante. Gracias por tus contribuciones, son siempre excelentes.
>
> En cuanto tenga tiempo he de publicar esta y varias cosillas pero he de
> documentarlas y preparar unos manualillos.
>
>
> Por cierto no tengo ni idea de como publicar en la Wiki ya que lo que he
> publicado hasta el momento ha sido en xailer.info
>
> Lo intento y si no lo consigo ya os pregunto.
>
> Salu2.
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
PILO
Mensajes: 583
Registrado: Vie Jul 06, 2007 5:18 pm

Word desde Xailer.

Mensaje por PILO »

Puedes cargar un ejemplo pequeño de ellos o me los puedes mandar al privado
srmpilo[arroba]gmail[punto]com
Gracias de antemano.
"Bingen Ugaldebere" <bingen@muninser.com> escribió en el mensaje
news:[email=48d87692@ozsrv2.ozlan.local...]48d87692@ozsrv2.ozlan.local...[/email]
> Perdón por el retraso en la lectura Xevi pero he tenido plaga de
> "bichos" por el disco duro, vamos una put.......
>
> Yo modifique y amplié la clase tWord original de Sebastian Almirón para
> Xailer y aunque veo que te han mandado ya alguna si quieres otra opción
> aquí va esta.
>
> SI necesitas alguna aclaración me lo dices.
>
> ::oWord := TWord():New()
>
> If !::oWord:lInstalled
> Alert( "ERROR! Word no esta instalado. [" + Ole2TxtError()+ "]" )
> Return Nil
> EndIf
>
>
> WITH OBJECT ::oWord
> :NewDoc( "Ficha "+::oDemandantes:Nombre+"
> "+::oDemandantes:Apellidos,;
> Application:cDirectory+"PlantillasFicha.Doc")
>
> :Replacefields({::oDemandantes})
>
> :ReplaceArrays({::oMemPermisosConducir,::oMemForm,::oMemForm Comp,::oMemIdiomas,::oMemExperiencia},3)
>
> :View()
> END
>
>
------------------------------------------------------------ --------------------
> /*
> * Proyecto: Microsoft Word Management Class via OLE
> * Fichero: TWord.prg
> * Autor: Bingen Ugaldebere - Mungia Informática
> * Based in a original class for FW 16bits from Sebastian Almirón
> * Fecha: 21/08/2007 - 10/09/2007
> */
>
> #include "Xailer.ch"
> #include "tWord.ch"
>
> CLASS TWord
>
> Data oWord
> Data cDocName
> Data OleDocs
> Data lInstalled Init .T.
> Data OleDocs
> Data oDocument
> Data oText
> Data oSelection
> Data oRange
> Data cDocName
> Data nLine,nCol, nPage
> Data nYoffset, nXoffset
> Data lStartpag
> Data lOverflowing
> Data nlastrow
> Data cTextOverflow
> Data lSetCm
>
> METHOD New()
> METHOD NewDoc( cDocName, cTemplate )
> METHOD View()
> METHOD Hide()
> METHOD OpenDoc( cDocName, lReadonly )
> METHOD Preview()
> METHOD SetLandScape()
> METHOD SetPortrait()
> METHOD Setpaper(nWidth, nHeight, lLandscape)
> METHOD CloseDoc(oDoc)
> METHOD End()
> METHOD CheckSpelling()
>
> METHOD GoBottom()
> METHOD Gotop()
> METHOD GoEnd()
> METHOD GoInit()
> METHOD GoUp(nLines)
> METHOD GoDown(nLines)
> METHOD Goto(nLin,nCol)
> METHOD GoRight(nChar)
> METHOD GoLeft(nChar)
> METHOD GotoPage(nPage)
> METHOD GotoHeader()
> METHOD GotoFooter()
> METHOD GotoDocument()
>
> METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo,
> nItem, nCopias, cPages)
> METHOD Protect(cPassword,nMode)
> METHOD UnProtect(cPassword)
> METHOD Save(cDocName)
> METHOD Say( nLin,nCol,cText,oFont,nSizeHorz,nClrText,nBkMode,nPad,
> nAltura, nClrIndex, lVertAdjust )
> METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor )
> METHOD SetCm()
> METHOD GetTextHeight( oFont )
> METHOD GetTextWidth(cText, oFont)
> METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext,
> nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation)
> METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo,
> nrotacion )
> METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo,
> nrotation, lPicTextured )
>
> METHOD FullView()
> METHOD Pages()
> METHOD Find( cText )
> METHOD Replace( cOld, cNew )
> METHOD ReplaceFields(aDatasets)
> Method ReplaceArrays(aDatasets,nColumnaInicial)
> METHOD ListOfFields(aDatasets,lShow)
> METHOD NewPage()
>
> METHOD SelectAll()
> METHOD SelCurrentLine()
> METHOD SelCurrentPara()
> METHOD UnSelect()
>
> METHOD Cut() INLINE ::oText:Cut()
> METHOD Copy() INLINE ::oText:Copy()
> METHOD Paste() INLINE ::oText:Paste()
>
> ENDCLASS
>
> METHOD NEW() CLASS TWord
>
> TRY
> ::oWord := GetActiveObject( "Word.Application" )
> CATCH
> TRY
> ::oWord := CreateObject( "Word.Application" )
> CATCH
> ::lInstalled := .F.
> END
> END
>
> Return Self
>
> //Document
> management__________________________________________________ ________
> METHOD NewDoc( cDocName, cTemplate ) CLASS TWord
> DEFAULT cDocName TO "Documento1"
> DEFAULT cTemplate TO ""
>
> ::oWord:Documents:Add(cTemplate)
>
> ::OleDocs := ::oWord:Documents
> ::oDocument := ::oWord:ActiveDocument
> ::oText := ::oWord:Selection
> ::cDocName := cDocName
> ::nLine := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::lstartpag := .t.
> ::oSelection := ::oDocument
> ::oRange := ::oDocument:Range(1,1)
> ::lSetcm := .f.
> ::lOverflowing := .f.
> ::nlastrow := 0
> ::ctextoverflow := ''
>
> Return Nil
>
> METHOD OpenDoc( cDocName, lReadOnly )
> Local lOk := .t.
> Default lReadOnly To .F.
>
> ::OleDocs := ::oWord:Documents
> If File( cDocName )
> ::cDocName := cDocName
> ::oDocument := ::Oledocs:Open(::cDocName,,lReadOnly)
> if valtype(::oDocument) <> 'O'
> lOk := .f.
> else
> ::oText := ::oWord:Selection
> ::nLine := 0
> ::nCol := 0
> ::nPage := 0
> ::nYoffset := 0
> ::nXoffset := 0
> ::oSelection := ::oDocument
> ::oRange := ::oDocument:Range(1,1)
> ::lstartpag := .t.
> ::lsetcm := .f.
> ::lOverflowing := .f.
> ::nlastrow := 0
> ::ctextoverflow := ''
> Endif
> else
> MsgStop("Word File Not Found"+CRLF+CRLF+cDocName )
> lOk := .f.
> endif
>
> Return lOk
>
> METHOD Save(cDocName) CLASS TWord
> DEFAULT cDocName To ::cDocName
> ::oDocument:SaveAs( cDocName )
> Return Nil
>
> METHOD PrintDoc(lBackground, lAppend, nRange, cOutputFile, nFrom, nTo,
> nItem, nCopias, cPages) CLASS TWord
> Local Csinpath, cPath
> DEFAULT lBackground To .f.
> DEFAULT lAppend To .f.
> DEFAULT nRange To 0
> DEFAULT cOutputFile To ''
> DEFAULT nFrom To ''
> DEFAULT nTo To ''
> DEFAULT nItem To 0
> DEFAULT nCopias To 1
> DEFAULT cPages To ''
>
> If !Empty(nFrom) .Or. !Empty(nTo)
> nRange := 3
> nFrom := Alltrim(Str(Int(nFrom)))
> nTo := Alltrim(Str(Int(nTo)))
> Endif
>
> If Empty(cOutputFile)
> ::oDocument:PrintOut(lbackground,lappend,int(nRange),'',nfro m, nto,
> nitem,ncopias, cpages )
> Else
> cPath := FilePath(cOutputFile)
> If !Empty(cPath) .and. cPath <>''
> ::OleWord:ChangeFileOpenDirectory(cPath)
> Endif
> cSinpath := FileFullName(cOutputFile)
> ::OleWord:PrintOut(lbackground,lappend,int(nRange),csinpath, nfrom,
> nto, nitem, ncopias, cpages )
> Endif
> Return Nil
>
> METHOD CloseDoc(oDoc,lSaveChanges) CLASS TWord
> DEFAULT oDoc To ::oDocument
> DEFAULT lSaveChanges To .F.
> oDoc:Close(If(lSaveChanges,0,-1)) // 0=Close without save changes -1=Close
> saving changes
> Return Nil
>
> METHOD End(lSaveChanges) CLASS TWord
> DEFAULT lSaveChanges To .F.
> ::OleDocs:Close(,lSaveChanges)
> ::oWord:Quit()
> ::oText := NIL
> ::oDocument := NIL
> ::OleDocs := NIL
> ::oWord := NIL
> Return nil
>
> //Presentation
> Management__________________________________________________ _____
> METHOD View(nView) CLASS TWord
> Default nView To 1
> ::oWord:Visible := .T.
> ::oWord:WindowState := 2
> ::oWord:WindowState := nView // 1=Maximize 2=Minimize 3=Normal
> Return Nil
>
> METHOD Hide() CLASS TWord
> ::oWord:Visible := .F.
> Return Nil
>
> METHOD FullView() CLASS TWord
> LOCAL oWindow, oView
>
> oWindow := ::oDocument:ActiveWindow
> oView := oWindow:View
> oView:FullScreen:=.T.
> ::View()
> release oView
> Return nil
>
> METHOD SetPortrait() CLASS TWord
> Local oPageSetup := ::oDocument:PageSetup
> oPageSetup:Orientation:=wdOrientPortrait
> release oPageSetup
> Return Nil
>
> METHOD SetLandScape() CLASS TWord
> Local oPageSetup := ::oDocument:PageSetup
> oPageSetup:Orientation:=wdOrientLandscape
> release oPageSetup
> Return Nil
>
> METHOD Setpaper(nWidth, nHeight, lLandscape) CLASS TWord
> Local oPage
> DEFAULT nWidth To 21
> DEFAULT nHeight To 29.7
> DEFAULT lLandscape To .F.
> oPage := ::oDocument:Pagesetup
>
> If lLandscape
> oPage:Orientation:=wdOrientLandscape
> Else
> oPage:Orientation:=wdOrientPortrait
> Endif
>
> oPage:PageWidth :=nWidth*28.35
> oPage:PageHeight :=nHeight*28.35
>
> release opage
>
> Return Nil
>
> METHOD Preview() CLASS TWord
> ::oWord:PrintPreview()
> ::oDocument:PrintPreview()
> ::View()
> Return nil
>
> //Positioning_______________________________________________ ___________________
> METHOD Gotop() CLASS TWord
> ::oText:HomeKey(wdStory,wdMove)
> Return nil
>
> METHOD GoBottom() CLASS TWord
> ::oText:EndKey(wdStory,wdMove)
> Return nil
>
> METHOD GoInit() CLASS TWord
> ::oText:HomeKey()
> Return nil
>
> METHOD GoEnd() CLASS TWord
> ::oText:EndKey()
> Return nil
>
> METHOD GoDown(nLines) CLASS TWord
> Default nLines To 1
> ::oText:MoveDown(wdLine,nLines,wdMove)
> Return nil
>
> METHOD GoUp(nLines) CLASS TWord
> Default nLines To 1
> ::oText:MoveUp(wdLine,nLines,wdMove)
> Return nil
>
> METHOD GoRight(nChar) CLASS TWord
> Default nChar To 1
> ::oText:MoveRight(wdCharacter,nChar,wdMove)
> Return nil
>
> METHOD GoLeft(nChar) CLASS TWord
> Default nChar To 1
> ::oText:MoveLeft(wdCharacter,nChar,wdMove)
> Return nil
>
> METHOD Goto(nLin,nCol) CLASS TWord
> Local n:=1, oProperties,oLines
> Default nCol to 1
>
> CursorWait()
> oProperties:=::oDocument:BuiltInDocumentProperties
> oLines:=oProperties:Item(wdPropertyLines)
>
> If oLines:Value>nLin
> ::Gotop()
> ::GoDown(nLin-1)
> Else
> For n=1 to nLin-oLines:Value
> ::oText:TypeText( Chr(13) )
> ::GoBottom()
> Next
> Endif
>
> ::GoInit()
> ::GoRight(nCol-1)
>
> CursorArrow()
> Return nil
>
> METHOD GotoPage(nPage) CLASS TWord
> Local n:=1
> Default nPage To 1
> ::GoTop()
> For n:=1 to nPage-1
> ::oText:GotoNext(wdGoToPage)
> Next
> Return Nil
>
> METHOD GotoHeader() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekCurrentPageHeader
> ::oSelection := ::oText:HeaderFooter
> release oWindow, oView
> Return Nil
>
> METHOD GotoFooter() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekCurrentPageFooter
> ::oSelection := ::oText:HeaderFooter
> release oWindow, oView
> Return Nil
>
> METHOD GotoDocument() CLASS TWord
> Local oWindow := ::oDocument:ActiveWindow
> local oView := oWindow:View
> oView:SeekView:=wdSeekMainDocument
> ::oSelection := ::oDocument
> release oWindow, oView
> Return Nil
>
>
>
> //Other features
> METHOD CheckSpelling() CLASS TWord
> ::oDocument:CheckSpelling()
> Return nil
>
> METHOD Protect(cPassword,nMode) CLASS TWord
> DEFAULT nMode To 3
> If cPassword=Nil
> Msginfo("ERROR: Imposible proteger Documento sin un paswword")
> Return .F.
> Endif
>
> ::oDocument:Protect( nMode, .F. , cPassword )
>
> Return .T.
>
> METHOD UnProtect(cPassword) CLASS TWord
> ::oDocument:UnProtect( cPassword )
> return nil
>
> METHOD SetCm() CLASS TWord
> ::lSetCm := .t.
> Return Nil
>
> METHOD GetTextHeight( oFont ) CLASS TWord
> Local nHeight
> If ::lsetcm
> nHeight := oFont:nHeight/28.35
> Else
> nHeight := oFont:nHeight
> Endif
> Return nHeight
>
>
> METHOD GetTextWidth(cText, oFont) CLASS TWord
> Local nWidth
> If oFont:nHeight > 0
> nWidth := (oFont:nHeight/1.6)*len(ctext)
> Else
> nWidth :=((oFont:nHeight*-1)/1.6)*len(ctext)
> Endif
> Return nWidth
>
> METHOD TextBox( nTop, nLeft, nBottom, nRight, cText, oFont, nclrtext,
> nClrBack, nJustify, afondo, aLine, lvertadjust, nOrientation) CLASS TWord
> local oShapes,oCuadro,oFill,oLine, oFontC, oText, oCuadroText, cText2,
> lCorta, oParagraph, oFillColor
> local nPad := 0, n, oWrap, nheighttext, lnocabe := .f., nheightbox:= 0
>
> DEFAULT nTop To 0
> DEFAULT nLeft To 0
> DEFAULT nBottom To 10
> DEFAULT nRight To 10
> DEFAULT cText To ' '
> DEFAULT oFont To TFont():New()
> DEFAULT nClrText To RGB(0,0,0)
> DEFAULT nJustify To 0
> DEFAULT afondo To {}
> DEFAULT aLine To {}
> DEFAULT lvertadjust To .f.
> DEFAULT nOrientation To 1
>
> nheighttext := oFont:nHeight
>
> If nOrientation > 3
> nOrientation := 1
> Endif
>
> do case
> case nJustify = 1
> nPad := 2
> case nJustify = 2
> nPad := 1
> case nJustify = 6
> nPad := 0
> endcase
>
> if ::lsetcm
> nTop := nTop*28.35
> nLeft := nLeft*28.35
> nBottom := nBottom*28.35
> nRight := nRight*28.35
> endif
>
>
> oShapes := ::oSelection:Shapes
> oCuadro := oShapes:AddTextbox(
> nOrientation,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBot tom-nTop) )
> oFill := oCuadro:Fill
>
> // OleSetProperty( oCuadro, 'RelativeHorizontalPosition',1)
> // OleSetProperty( oCuadro, 'RelativeVerticalPosition',1)
>
> //Fill
> for n = 1 to len(afondo)
> do case
> case n = 1 .and. afondo[n] <> NIL
> oFillColor := oFill:ForeColor
> oFillColor:RGB:=afondo[1]
> case n = 2 .and. afondo[n] <> NIL
> oFillColor := oFill:BackColor
> oFillColor:RGB:=afondo[2]
> case n = 3 .and. afondo[n] <> NIL
> oFill:Transparency:=afondo[3]
> case n = 4 .and. afondo[n] <> NIL
> oFill:TwoColorGradient( afondo[4], afondo[5] )
> case n = 6 .and. afondo[n] <> NIL
> oFill:Patterned( afondo[6] )
> case n = 7 .and. afondo[n] <> NIL
> oFill:PresetTextured( afondo[7] )
> case n = 8 .and. afondo[n] <> NIL
> oFill:UserTextured( afondo[8] )
> endcase
> next n
>
> //Line de contorno
> oLine := oCuadro:Line
>
> for n = 1 to len(aLine)
> do case
> case n = 1
> oLine:Weight:= aLine[1]
> if aLine[1] = 0
> oLine:Visible:= 0
> endif
> case n = 2
> oLine:ForeColor:=aLine[2]
> case n = 3
> oLine:BackColor:=aLine[3]
> case n = 4
> oLine:Transparency:=aLine[4]
> case n = 5
> oLine:DashStyle:=aLine[5]
> case n = 5
> oLine:Style:=aLine[6]
> endcase
> next n
>
>
> oCuadroText := oCuadro:TextFrame
> oText := oCuadroText:TextRange
> oFontC := oText:Font
>
> *oFontC:Name :=oFont:cName
> *oFontC:Size :=INT(oFont:nHeight)
> *oFontC:Bold :=oFont:lBold
> *oFontC:Color:=nclrtext
>
> *oText:HighlightColorIndex:=nClrBack
>
> oText:Text:=cText
>
> oParagraph := oText:ParagraphFormat
>
>
> oParagraph:Alignment:=nPad
>
>
> if lvertadjust
> nheightbox := 0
> oCuadro:Height:=nheightbox
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nheightbox + nHeighttext //+
> OleGetProperty(oParagraph,'SpaceBefore')
> do whil lnocabe = .t. .and. nheightbox <= nBottom - nTop
> oCuadro:Height:=nheightbox
> oText:Text:=cText
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nheightbox + nHeighttext //+
> OleGetProperty(oParagraph,'SpaceBefore')
> enddo
>
> else
> ::oDocument:ComputeStatistics( 2,.t.)
> lnocabe := oCuadroText:Overflowing
> nheightbox := nBottom
> endif
>
> lcorta := lnocabe
> cText2 := cText
> do whil lcorta .and. !empty(cText2)
> cText2 := Dellastword(cText2)
> oText:Text:= cText2
> ::oDocument:ComputeStatistics( 2,.t.)
> lcorta := oCuadroText:Overflowing
> enddo
>
> ::ctextoverflow := strtran(cText, cText2, '')
> ::loverflowing := lnocabe
>
> release oParagraph, OLine, oFillColor, oFill, oFontC, oText,oCuadroText,
> oCuadro
>
> if lvertadjust
> if ::lsetcm
> ::nlastrow := (ntop + nheightbox)/28.35
> else
> ::nlastrow := ntop + nheightbox
> endif
> else
> if ::lsetcm
> ::nlastrow := nBottom/28.35
> else
> ::nlastrow := nBottom
> endif
> endif
>
> Return Nil
>
> static function dellastword(cText)
> Local sal := rtrim(cText)
> do whil !empty(sal)
> sal := substr(sal,1, len(sal)-1)
> if substr(sal, len(sal), 1) = chr(32) .or. substr(sal, len(sal), 1) =
> chr(13)
> exit
> endif
> enddo
> return sal
>
> METHOD Pages() CLASS TWord
> Local oProperties,oPages
>
> oProperties:=::oDocument:BuiltInDocumentProperties
> oPages:=oProperties:Item(wdPropertyPages)
>
> Return oPages:Value
>
> METHOD NewPage() CLASS TWord
> ::GoBottom()
> ::oText:InsertBreak(wdPageBreak)
> ::oText:GotoNext(wdGoToPage)
> ::Write(chr(31)) //Es necesario para ponder vincular los cuadros de
> texto a una pagina determinada.
> Return Nil
>
> //Put elements on document
> METHOD Say( nLin,nCol,cText,oFont, nSize, lBold, lShadow, nColor ) CLASS
> TWord
> Local cFont := "Arial" //oFont:cFaceName
> Default nLin to 0
> Default nCol to 0
>
> If nLin>0 .Or. nCol>0
> ::Goto(nLin,nCol)
> Endif
>
> ::Write( cText, cFont, nSize, lBold, lShadow, nColor )
> Return Nil
>
> METHOD Write( cText, cFont, nSize, lBold, lShadow, nColor ) CLASS TWord
> Local oFont := ::oText:Font
>
> oFont:Name :=cFont
> oFont:Size :=nSize
> oFont:Bold := lBold
> oFont:ColorIndex:=nColor
> oFont:Emboss :=lShadow
>
> ::oText:TypeText( cText )
> oFont:Reset()
> release oFont
> Return nil
>
>
> METHOD AddImage( nTop, nLeft, nBottom, nRight, cImage, aLine, ntipo,
> nrotacion ) CLASS TWord
>
> ::Box(nTop, nLeft, nBottom, nRight, {,,,,,,,cImage}, aLine, ntipo,
> nrotacion, .t.)
>
> Return Nil
>
> METHOD Box( nTop, nLeft, nBottom, nRight, afondo, aLine, ntipo, nrotation,
> lPicTextured ) CLASS TWord
> Local oShapes,oShapBox, oFill, oFillColor, oLine, n
>
> DEFAULT afondo To {}
> DEFAULT aLine To {}
> DEFAULT ntipo To 1
> DEFAULT nrotation To 0
> DEFAULT lPicTextured To .f.
>
> ::nLastRow := nBottom
> if ::lsetcm
> nTop := nTop*28.35
> nLeft := nLeft*28.35
> nBottom := nBottom*28.35
> nRight := nRight*28.35
> endif
> nRight := nRight - nLeft
> nBottom := nBottom - nTop
>
> oShapes := ::oSelection:Shapes
>
> oShapBox := oShapes:AddShape( ntipo,nLeft,nTop,nRight,nBottom )
>
> oShapBox:RelativeHorizontalPosition:=1
> oShapBox:RelativeVerticalPosition:=1
>
> oFill := oShapBox:Fill
>
> oShapBox:Rotation:=nrotation
>
> For n = 1 to len(afondo)
> do case
> case n = 1 .and. afondo[n] <> NIL
> oFillColor := oFill:ForeColor
> oFillColor:RGB:=afondo[1]
> case n = 2 .and. afondo[n] <> NIL
> oFillColor := oFill:BackColor
> oFillColor:RGB:=afondo[2]
> case n = 3 .and. afondo[n] <> NIL
> oFill:Transparency:=afondo[3]
> case n = 4 .and. afondo[n] <> NIL
> oFill:TwoColorGradient( afondo[4], afondo[5] )
> case n = 6 .and. afondo[n] <> NIL
> oFill:Patterned( afondo[6] )
> case n = 7 .and. afondo[n] <> NIL
> oFill:PresetTextured( afondo[7] )
> case n = 8 .and. afondo[n] <> NIL
> if lPicTextured = .t.
> oFill:UserPicture( afondo[8] )
> else
> oFill:UserTextured( afondo[8] )
> endif
> endcase
> Next
>
> oLine := oShapBox:Line
>
> For n = 1 to len(aLine)
> do case
> case n = 1
> oLine:Weight:= aLine[1]
> if aLine[1] = 0
> oLine:Visible:=0
> endif
> case n = 2
> oLine:ForeColor:=aLine[2]
> case n = 3
> oLine:BackColor:= aLine[3]
> case n = 4
> oLine:Transparency:= aLine[4]
> case n = 5
> oLine:DashStyle:= aLine[5]
> case n = 5
> oLine:Style:= aLine[6]
> endcase
> Next
>
> release oShapes,oShapBox, oFill, oFillColor, oLine
>
> Return Nil
>
> //Find &
> replace_____________________________________________________ __________
> METHOD Find( cText ) CLASS TWord
> LOCAL oText, oFind
>
> ::Gotop()
> oText :=::oSelection:Range()
> oFind := oText:Find
>
> oFind:Text :=cText
> oFind:Forward :=.T.
> oFind:Wrap :=INT(1)
> oFind:Format :=.f.
> oFind:MatchCase :=.f.
> oFind:MatchWholeWord :=.t.
> oFind:MatchWildcards :=.f.
> oFind:MatchSoundsLike :=.f.
> oFind:MatchAllWordForms :=.f.
>
> oFind:Execute()
> If oFind:Found
> ::oText:Startof(wdLine) //Pendiente
> ::oText:Moveend(wdLine)
> Endif
>
> release oFind,oText
>
> Return oFind:Found
>
> METHOD Replace( cOld, cNew ) CLASS TWord
> LOCAL oText, oFind, oReplace
>
> oText :=::oSelection:Range()
> oFind := oText:Find
>
> oFind:Text :=cOld
> oFind:Forward :=.T.
> oFind:Wrap :=INT(1)
> oFind:Format :=.f.
> oFind:MatchCase :=.f.
> oFind:MatchWholeWord :=.t.
> oFind:MatchWildcards :=.f.
> oFind:MatchSoundsLike :=.f.
> oFind:MatchAllWordForms :=.f.
>
> oFind:Execute()
> DO WHILE oFind:Found
> oText:Text:=cNew
> oFind:Execute()
> Enddo
>
> release oReplace,oFind,oText
>
> Return Nil
>
>
> //Selection of document
> parts_____________________________________________________
> METHOD SelectAll() CLASS TWord
> ::oRange:=
> ::oDocument:Range(::oDocument:Content:Start,::oDocument:cont ent:End)
> ::oRange:Select()
> Return Nil
>
> METHOD UnSelect() CLASS TWord
> ::oRange:= ::oDocument:Range(0,0)
> ::oRange:Select()
> Return Nil
>
> METHOD SelCurrentLine() CLASS TWord
> Local Start, end, oProperties
> ::oText:Startof(wdLine)
> ::oText:Moveend(wdLine)
> Return Nil
>
> METHOD SelCurrentPara() CLASS TWord
> Local Start, end, oProperties
> ::oText:Startof(wdParagraph)
> ::oText:Moveend(wdParagraph)
> Return Nil
>
> METHOD ListOfFields(aDatasets, lShow) CLASS TWord
> Local oForm, aFields:={}, nField, oField, oBrw, nAt:=0, x:=0, lOk:=.F.
> Local cName:="", nItem:=0, nNumber:=0
>
> Default lShow To .T.
>
> CursorWait()
>
> For nItem:=1 to Len(aDataSets)
>
> cName:=aDataSets[nItem]:cName
> cName:=If(aDataSets[nItem]:Cargo<>Nil,aDataSets[nItem]:Cargo,cName)
>
> For nField:= 1 To Len(aDataSets[nItem]:aFields)
>
> Aadd(aFields,{Upper(cName)+":"+Alltrim(aDataSets[nItem]:aFields[nField]:cName),;
> ToString(aDataSets[nItem]:aFields[nField]:Value)})
> Next
>
> Next
>
> CursorArrow()
>
> If !lShow
> Return aFields
> Endif
>
> DEFINE FORM oForm TITLE "List of Fields" OF GetActiveform() ;
> SIZE 363, 427 BORDERSTYLE bsDIALOG
>
> @ 25, 10 ARRAYBROWSE oBrw Size 343,300 Items aFields Headers
> {"Dbf","Field"} OF oForm
>
> oBrw:lRecordSelector :=.F.
> oBrw:nMarqueeStyle :=bmHIGHLROWRC
> oBrw:nClrAltPane :=clLtGray
> oBrw:OnDblClick :={|| (lOk := .T., nAt:=oBrw:nArrayAt,
> oForm:Close()) }
>
> @ 364, 20 BUTTON CAPTION LT( XA_MSG_ACEPTAR ) SIZE 80, 25 OF oForm ;
> ACTION (lOk := .T.,
> nAt:=oBrw:aArrayData[oBrw:nArrayAt,Len(oBrw:aArrayData[1])],
> oForm:Close()) Default
>
>
> @ 364, 250 BUTTON CAPTION LT( XA_MSG_IMPRIMIR ) SIZE 80, 25 OF oForm
> ;
> ACTION PrnARRAY(aFields)
>
> oBrw:lFilterBar:=.F.
> oBrw:lAutoOrder:=.t.
>
> ACTIVATE FORM oForm MODAL CENTER
>
> Return aFields
>
> METHOD ReplaceFields(aDatasets) CLASS TWord
> Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
>
> CursorWait()
>
> For nField:= 1 to Len(aFields)
>
> ::Replace("{"+aFields[nField,1]+"}",Alltrim(ToString(aFields[nField,2])))
> Next
>
> CursorArrow()
>
> Return aFields
>
> METHOD ReplaceArrays(aDatasets,nColumnaInicial) CLASS TWord
> Local aFields:=::ListOfFields(aDatasets, .F.), nField:=0
> Local aDatabases:={}, nDB, nLine, nColumn, cTexto:=""
>
> Default nColumnaInicial To 1
>
> CursorWait()
> FOR nDB := 1 TO Len( aDatasets )
>
> cTexto:=""
> For nLine:=1 to Len(aDatasets[nDB]:aData)
> For nColumn:=If(nColumnaInicial>1,nColumnaInicial,1) to
> Len(aDatasets[nDB]:aData[nLine])
> Do Case
> Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="L"
>
> cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] , "S","N")
> Case Valtype(aDatasets[nDB]:aData[nLine,nColumn])="N"
>
> cTexto:=cTexto+Chr(9)+If(aDatasets[nDB]:aData[nLine,nColumn] >0,;
>
> Alltrim(ToString(aDatasets[nDB]:aData[nLine,nColumn]))," ")
> OtherWise
>
> cTexto:=cTexto+Chr(9)+Alltrim(ToString(aDatasets[nDB]:aData[ nLine,nColumn]))
> EndCase
> Next
> cTexto:=cTexto+Chr(13)
> Next
> ::Replace("{"+aDatasets[nDB]:Cargo+":Tabla}",cTexto)
>
> NEXT
> CursorArrow()
>
> Return Nil
>
>
> ******* IMPRIMIR ARRAY
> STATIC FUNCTION PrnARRAY(aItems,aHeads,cTitle,cText)
> Local ofrmPreview, oFont, oPen, n := 100, nItem:=0, cHead:=""
> Local aDatos:={}, aLen:={}, nL:=0, nC:=0, cTexto:="", lSalir:=.F.,
> nNumpage:=0
>
> DEFAULT aHeads To {}
> DEFAULT cTitle To ""
> DEFAULT cText To ""
>
> CursorWait()
>
> //Calcular Numero de columnas e inicializar longitudes de columna
> aSize(aLen,If(ValType(aItems[1])="A",Len(aItems[1]),1))
> aFill(aLen,0)
>
> //Si no hay cabeceras crear un array de cabeceras a ""
> If Len(aHeads)=0
> aSize(aHeads,Len(aLen))
> aFill(aHeads,"")
> EndIf
>
> //Calcular anchura máxima de cada columna
> For nC:=1 to Len(aLen)
> For nL:=1 to Len(aItems)
> aLen[nC]:=Max(aLen[nC],Len(Alltrim(ToString(aItems[nL,nC]))) )
> aLen[nC]:=Max(aLen[nC],Len(Alltrim(aHeads[nC])))
> Next
> Next
>
> //Si hay cabeceras crear el literal de cabecera
> If Len(aHeads)>0
> For nC:=1 to Len(aLen)
> cHead:=cHead+PadR(aHeads[nC],aLen[nC])+" "
> Next
> Endif
>
> //Crear el literal de cada línea del Array y cargar a aDatos
> For nL:=1 to Len(aItems)
> cTexto:=""
> For nC:=1 to Len(aLen)
> Do Case
> Case ValType(aItems[nL,nC])="C"
> cTexto:=cTexto+PadR(aItems[nL,nC],aLen[nC])+" "
> Case ValType(aItems[nL,nC])="N"
> cTexto:=cTexto+Padl(Alltrim(Str(aItems[nL,nC])),aLen[nC])+"
> "
> Case ValType(aItems[nL,nC])="D"
> cTexto:=cTexto+PadR(Dtoc(aItems[nL,nC]),10)+" "
> EndCase
> Next
> Aadd(aDatos,cTexto)
> Next
>
>
> //Comienza impresión
> DEFINE FONT oFont NAME "COURIER NEW"
>
> Printer:cJobTitle := cTitle
> Printer:lPreview := .t.
> Printer:StartDoc()
> Printer:oCanvas:nMapMode := mmHIMETRICS
>
> Do While !lSalir
> Printer:StartPage()
> WITH OBJECT Printer:oCanvas
> :oFont := oFont
> :oPen := oPen
>
> :nMapMode := mmSIMULCHAR
> :nTextAlignment:=taCENTER
> :oFont:nSize := 14
> :oFont:lBold := .T.
> :oFont:lUnderline := .T.
> :TextOut( 1, 1, cTitle,70, CLR_BLUE)
>
> :nTextAlignment:=taLEFT
> :oFont:nSize := 12
> :TextOut( 2, 3, AllTrim(cHead),30, CLR_BLACK)
>
> :oFont:lBold := .F.
> :oFont:lUnderline := .F.
>
> For n := 1 to :TextLines()-5
> If ++nItem<=Len(aDatos)
> :TextOut( 2, n+4, aDatos[nItem],30, CLR_BLACK)
> Else
> lSalir:=.T.
> Exit
> Endif
> Next
> :nTextAlignment:=taCENTER
> :TextOut( 1, :TextLines(), "-
> "+Alltrim(ToString(++nNumpage))+" -",80, CLR_BLUE)
>
> END WITH
> Printer:EndPage()
> Enddo
> Printer:EndDoc()
> Printer:Preview()
> oFont:Destroy()
>
> CursorArrow()
>
> Return Nil
>
>
>
Avatar de Usuario
Carlos Ortiz
Mensajes: 872
Registrado: Mié Jul 01, 2009 5:44 pm
Ubicación: Argentina - Córdoba
Contactar:

Word desde Xailer.

Mensaje por Carlos Ortiz »

Hola Vikthor tanto tiempo, un grande y coordial saludo de mi parte.
Carlos Ortiz.
"Vikthor" <victor@gdeiman.com> escribió en el mensaje
news:[email=48d7ddef@ozsrv2.ozlan.local...]48d7ddef@ozsrv2.ozlan.local...[/email]
José David Angulo
La clase TExcelScript es únicamente para uso exclusivo con el "otro"
producto.
Las modificaciones hechas por un servidor a la clase TWord son también para
uso exclusivo del "otro" producto.
Atentamente :
Un usuario del "otro" producto.
jajajajajajajajajajajajaja, perdón , perdón , perdón............pero no me
pude contener.
Un saludo a todos por acá.
Después de varios años usando el "otro" producto, hoy comienzo mi camino de
la mano de Xailer.
Dicho lo cual....... ustedes tranquilos y yo sereno, que ya andaré dando
dejando mis dudas en este foro lleno de amigos.
Vikthor
Posdata :
¿ Aquí no me van a censurar ?
"José David Angulo" <gerencia@microexpressltda.com> escribió en el mensaje
de noticias news:[email=48d25301@ozsrv2.ozlan.local...]48d25301@ozsrv2.ozlan.local...[/email]
Xevi,
La estoy utilizando conjuntamente con la clase TExcelScript y lo que hago
es combinar correspondencia yo le dejo todo el trabajo a Word que cambie los
datos del documento modelo, solo le envió la hoja de excel con los datos y
listo, si el usuario es un genio con Word y Excel que arme su archivo con
word y yo le mando los datos con combinar correspondencia en Word.
Function combinarCorrespondencia(cFileWord, cFileXLS)
Local oWord
oWord := TWord():New()
oWord:OpenDoc(GetCurrentDirectory()+"Documentos"+cFileWord)
oWord:OpenDataSource(GetCurrentDirectory()+"Documentos"+cFileXLS)//
Abre el origen de datos para la combinación de correspondencia
//oWord:oMailMerge:Set( "Destination" , 1 ) // A la impresora
oWord:oMailMerge:Set( "Destination" , 0 ) // Nuevo documento
oWord:oMailMerge:Invoke( "Execute" )
oWord:Preview()
oWord:Close()
Return NIL
--
José David Angulo.
Auditoría y Sistemas Ltda.
Tel.(57) 5- 6643022 - 6644555
Cartagena - Colombia
jose.angulo@auditoriaysistemas.com
Xevi escribió:
José David,
esta clase compila perfectamente... Ahora bien, ¿podrías ponerme algun
ejemplillo de como utilizarla???
O si puedes ponerme una cuantas líneas de tu código... para ver como la
utilizas.
Gracias.
Un Saludo,
Xevi.
"José David Angulo" <gerencia@microexpressltda.com> escribió en el
mensaje news:[email=48d11fb5@ozsrv2.ozlan.local...]48d11fb5@ozsrv2.ozlan.local...[/email]
Xevi,
Esta es la que uso con Xailer no se si es la misma, mira a ver si te
sirve.
--
José David Angulo.
Auditoría y Sistemas Ltda.
Tel.(57) 5- 6643022 - 6644555
Cartagena - Colombia
jose.angulo@auditoriaysistemas.com
Xevi escribió:
Rene,
He intentado añadir esta clase a un proyecto hecho con Xailer...
donde #include "elotroproducto.ch"... "Xailer.ch"
Y lanza una pila de errores al compilar.
He intentado "depurarlo... pero me atasco en alguna parte.
Gracias.
Un Saludo,
Xevi.
Responder