FoxPro/Visual FoxPro - INSERTAR CAMPOS DE UNA TABLA FOX A WORD..

 
Vista:

INSERTAR CAMPOS DE UNA TABLA FOX A WORD..

Publicado por Juan Ayala (78 intervenciones) el 13/10/2008 20:54:37
Hola
Necesito insertar un campo en word, a partir de una tabla libre que lo hice justamente para que tome el dato necesario. trabajo con visualFox9 y desde mi formulario deseo imprimir un texto.doc donde figuren el nombre y demas datos de un registro de clientes.

Si alguien puede ayudarme seria de mucha ayuda.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:INSERTAR CAMPOS DE UNA TABLA FOX A WORD..

Publicado por sergio (737 intervenciones) el 14/10/2008 16:54:18
Te pasoun ejemplo que tengo, solo borra las lineas de codigo que no te sirve
PROCEDURE exportToWord_ar

#DEFINE lEnter CHR(13)
#DEFINE lTab CHR(9)
#DEFINE lSaltoPag CHR(12)

mPath = mPathAux + 'Presup_Neg_' + ALLT(STR(mFicha))

&& Recorto las Lineas de Separación
WAIT "Generando Presupuesto..." WIND NOWAIT
SELE todojun
GO TOP

DO WHILE !EOF()
IF RECNO() > 1
IF !EMPTY(SERVICIO)
SKIP -1
REPLACE DESCRIP WITH REPLICATE('_',93)
SKIP
ENDIF

IF ALLT(SERVICIO) = 'PAX'
IF mvalores
SKIP -5
REPLACE DESCRIP WITH REPLICATE('_',93)
SKIP 5
ELSE
SKIP -2
REPLACE DESCRIP WITH ''
SKIP 2
ENDIF
ENDIF
ENDIF
SKIP
ENDDO

lalias = ALIAS()
larchivo = 'A'+SYS(3)

CREATE CURSOR larchivo (imagen M)

APPE BLANK
APPE MEMO imagen FROM logofalabella.gif
COPY MEMO larchivo.imagen TO mPathAux + "logofalabella.gif"

APPE BLANK
APPE MEMO imagen FROM firma_presupuestos.bmp
COPY MEMO larchivo.imagen TO mPathAux + "firma_presupuestos.bmp"

SELECT &lalias
oWord=CreateObject("Word.Application")

WITH oWord
* .Visible=.T.

.Documents.Add
&& Seteos de Tipo de Hoja Carta

WITH oWord.ActiveDocument.PageSetup
*.LineNumbering.Active = 0
*.Orientation = 0
.TopMargin = 22
.BottomMargin = 22
.LeftMargin = 28
.RightMargin = 22
*.Gutter = 0
.HeaderDistance = 22
.FooterDistance = 22
.PageWidth = 612.1
.PageHeight = 792.1
*.FirstPageTray = 0
*.OtherPagesTray = 0
.SectionStart = 2
*.OddAndEvenPagesHeaderFooter = 0
*.DifferentFirstPageHeaderFooter = 0
*.VerticalAlignment = 0
*.SuppressEndnotes = 0
*.MirrorMargins = 0
*.TwoPagesOnOne = 0
*.GutterPos = 0
ENDWITH

oword.ActiveWindow.ActivePane.View.SeekView = 9 && wdSeekCurrentPageHeader

.Selection.MoveRight
.Selection.InlineShapes.AddPicture(mPathAux + "logofalabella.gif")
.Selection.MoveRight
.Selection.InsertAfter(space(8))
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 14
.Selection.Font.Bold = 1
.Selection.Font.Underline = 0
.Selection.ParagraphFormat.Alignment = 0

.Selection.MoveRight
.Selection.InsertAfter(mtitulo)
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 14
.Selection.Font.Bold = 1
.Selection.Font.Underline = 1
.Selection.ParagraphFormat.Alignment = 0

if msubtitulo
.Selection.MoveRight
.Selection.TypeParagraph
.Selection.InsertAfter(mtitulo1)
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 12
.Selection.Font.Bold = 1
.Selection.Font.Underline = 1
.Selection.ParagraphFormat.Alignment = 1
endif

oword.ActiveWindow.ActivePane.View.SeekView = 0 && wdSeekMainDocument

if msubtitulo
.Selection.MoveRight
.Selection.TypeParagraph
.Selection.InsertAfter('Operador Responsable :')
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 10
.Selection.Font.Bold = 1
.Selection.ParagraphFormat.Alignment = 0
endif

.Selection.Moveright
.Selection.TypeParagraph
.Selection.InsertAfter('Negocio : ' + ALLTRIM(STR(mFicha)) + space(31-len(ALLTRIM(STR(mFicha)))) + 'Vendedor: '+ mNomVendedor + space(27-len(mNomVendedor)) + 'Fecha: '+dtoc(date()))
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 10
.Selection.Font.Bold = 1
.Selection.Font.Underline = 0
.Selection.ParagraphFormat.Alignment = 0

.Selection.Moveright
.Selection.TypeParagraph
.Selection.InsertAfter('Pasajero: ' + UPPER(ALLTRIM(mpasajero)) + space(31-len(ALLTRIM(mpasajero))) + 'Teléfono: ')
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 10
.Selection.Font.Bold = 1
.Selection.Font.Underline = 0
.Selection.ParagraphFormat.Alignment = 0

.Selection.Moveright
.Selection.TypeParagraph
.Selection.InsertAfter('Sucursal: ' + ALLTRIM(mNomSucursal) + space(31-len(ALLTRIM(mNomSucursal))) + 'Horario : ')
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 10
.Selection.Font.Bold = 1
.Selection.ParagraphFormat.Alignment = 0
.Selection.Font.Underline = 0

.Selection.Moveright
.Selection.TypeParagraph
.Selection.InsertAfter(replicate('_',77))
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 12
.Selection.Font.Bold = 1
.Selection.ParagraphFormat.Alignment = 0
.Selection.Font.Underline = 0

.Selection.EndKey
.Selection.MoveDown
.Selection.TypeParagraph

.Selection.Font.Bold = 0
.Selection.ParagraphFormat.Alignment = 0
lEspacio = REPLICATE(lEnter,1)
.Selection.InsertAfter(lEspacio)

SCAN
.Selection.InsertAfter(DESCRIP)
.Selection.Font.Name = "Courier New"
.Selection.Font.Size = 10
.Selection.Font.Underline = 0

IF (AT('Pasajero',descrip)>0 and ;
AT('Documento',descrip)>0 and ;
AT('Telefono',descrip)>0 and ;
AT('Nacionalidad',descrip)>0 and ;
AT('Fecha Nac.',descrip)>0);
.or. at('NOMINA',descrip)>0

.Selection.Font.Bold = 1
ELSE
.Selection.Font.Bold = 0
ENDIF
.Selection.Moveright
.Selection.TypeParagraph

ENDSCAN

if mpie
oword.ActiveWindow.ActivePane.View.SeekView = 10 &&wdSeekCurrentPageFooter

.Selection.MoveRight
.Selection.InlineShapes.AddPicture(mPathAux + "firma_presupuestos.bmp")

oword.ActiveWindow.ActivePane.View.SeekView = 0 && wdSeekMainDocument
endif

&& Guardo el Archivo
IF FILE(mPath) && si existe el archivo, lo sobreescribo
DELE FILE (mPath)
.ActiveDocument.SaveAs(mPath)
ELSE
.ActiveDocument.SaveAs(mPath)
ENDIF

.Quit
WAIT CLEAR

ENDWITH

aviso('Se ha Generado el Archivo: ' + mPath,1)

RELEASE oWord
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:INSERTAR CAMPOS DE UNA TABLA FOX A WORD..

Publicado por Juan Ayala (78 intervenciones) el 20/10/2008 17:29:07
Muchas Gracias !!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:INSERTAR CAMPOS DE UNA TABLA FOX A WORD..

Publicado por Carlos Boza (1 intervención) el 10/04/2010 00:39:13
Hola, muy útil este código.

He programado bastante código usando VisualFox 6.0 y Excel (97/2003 y 2007) y no he tenido mayor problema.

Estoy comenzando a programar con VisualFox y Word.

Puedo abrir el documento, insertar texto y alinearlo pero no puedo hacer otras funciones como subrayado, negrita, etc.

Creo que el problema es que no he podido seleccionar una porción de texto. En Excel sería algo así como "oexcel..application.Range("a1").Select" pero ¿cómo es en Word?

También quisiera saber como seleccionar una imagen insertada. Yo incluí una así:
.Selection.InlineShapes.AddPicture(vimagen)
Se que puedo cambiar su tamaño con:
.Selection.InlineShapes(1).Height = 283.45 y
.Selection.InlineShapes(1).Width = 283.45
pero igual no puedo seleccionarla desde el código.

Le agradesco de antemano toda la colaboración.

Carlos Boza
Costa Rica
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:INSERTAR CAMPOS DE UNA TABLA FOX A WORD..

Publicado por Alejandro (1 intervención) el 28/06/2012 02:45:19
'--- Insertar Imagen
'.TypeParagraph()
Set colShapes = objDoc.Shapes
Set objShape = colShapes.AddPicture(\\ruta\tufoto.jpg",true,true,230,0,230,90)
Set colShapes = objDoc.Range()
' .TypeParagraph()

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar