souilahmedali
Messages postés8Date d'inscriptionlundi 20 octobre 2008StatutMembreDernière intervention 6 mai 2009
-
6 mai 2009 à 00:01
souilahmedali
Messages postés8Date d'inscriptionlundi 20 octobre 2008StatutMembreDernière intervention 6 mai 2009
-
6 mai 2009 à 16:44
je veut imprimer une table vfp déjà affichée sur une grid
j'ai trouvé quelque code mais ça se marche pas
*!* .ParagraphFormat.Alignment = wdAlignParagraphLeft
*!* .Font.Size = 12
*!* .Font.Name = "Times New Roman"
*!* .InsertParagraphAfter()
*!* .InsertParagraphAfter()
*!* .ParagraphFormat.Alignment = wdAlignParagraphLeft
*!* .InsertAfter(REPLICATE("Paragraph #1 is left aligned. "+;
*!* "Paragraph 2 is justified. ",4))
*!* .Collapse(wdCollapseEnd)
*!* .InsertParagraphAfter()
*!* .InsertParagraphAfter()
*!* .Collapse(wdCollapseEnd)
*!* .ParagraphFormat.Alignment = wdAlignParagraphJustify
*!* .InsertAfter(REPLICATE("This is a long paragraph that "+;
*!* "needs to wrap around a table that will fit in the "+;
*!* "paragraph, aligned at the right margin. ", 3))
*!* .Collapse(wdCollapseEnd)
*!* ENDwith
*!* Need a table of 4 rows, 3 columns, plus cells for labels and headings.
oWord.ActiveDocument.Tables.Add(oRange, 5, 3, 1, 0) && Word 2000 syntax
*!* Arguments are Range, #rows, #cols, [DefaultTableBehavior,] [AutoFitBehavior])
*!* Word 97 syntax is oWord.ActiveDocument.Tables.Add(oRange, 5, 4)
oTable = oWord.ActiveDocument.Tables(1) && Assign a table object
WITH oTable
.Columns.SetWidth(72,0) && 72 points/inch
.Rows.WrapAroundText = .T.
.Rows.RelativeHorizontalPosition = 0 && wdHorizontalPositionMargin
.Rows.HorizontalPosition = -999996 && wdTableRight
.Autoformat(2,.T.,.T.,.T.,.T.,.T.,.T.,.T.,.T.,.T.)
*!* (Format,ApplyBorders,ApplyShading,ApplyFont,ApplyColor,ApplyHeadingRows,
*!* ApplyLastRow,ApplyFirstColumn,ApplyLastColumn,AutoFit)
*!*================ selectio de table en curseur
SELECT * FROM upcmd INTO CURSOR wd
n=2
.Cell(1,1).Range.InsertAfter("num ligne")
.Cell(1,2).Range.InsertAfter("cod articl")
.Cell(1,3).Range.InsertAfter("nom articl")
scan
.Cell(n,1).Range.InsertAfter(STR(wd.cod_ligne))
.Cell(n,2).Range.InsertAfter(STR(wd.cod_articl))
.Cell(n,3).Range.InsertAfter(wd.nom_articl)
n=n+1
endscan
ENDwith
oRange = oTable.Range
oRange.Collapse(wdCollapseEnd) && Move insertion point beyond table
*!* WITH oRange
*!* .InsertAfter("The table goes before this sentence. ")
*!* .InsertAfter(REPLICATE("This is a long paragraph that "+;
*!* "needs to wrap around a table that will fit in the "+;
*!* "paragraph, aligned at the right margin. ",5))
*!* .InsertParagraphAfter()
*!* .InsertParagraphAfter()
*!* .InsertAfter("A New Paragraph")
*!* ENDwith
oWord.Visible = .T. && Inspect the results
MESSAGEBOX("Look at results in Word.")
&&oWord.Quit(.F.) && Don't save changes
ThisForm.Release
souilahmedali
Messages postés8Date d'inscriptionlundi 20 octobre 2008StatutMembreDernière intervention 6 mai 2009 6 mai 2009 à 00:04
exemple de code:
************* Beginning of code. ****************
PUBLIC oWord
oWord = CREATEOBJECT("Word.Basic")
WITH oWord
.AppShow && Makes Word Visible
.FileNewDefault && Opens up blank Word document
* The following Insert commands place the FoxPro fields into
* the Word document. You can change these commands to place
* any text in the document.
* Ensure that the table is already open. If only a portion
* of records are to be printed, change the EOF() to a certain
* number so that all of the records do not get processed.
* Example: DO WHILE RECNO() < 10
GO TOP
DO WHILE NOT EOF()
.Insert("Record: "+ALLTRIM(STR(RECNO())))
&& The above line shows the record number.
.InsertPara
.InsertPara
.Insert(ALLTRIM(nom)) && Field in the table.
.InsertPara
.Insert(address)
.InsertPara
.Insert(ALLTRIM(city)+", "+state+" "+zipcode)
.InsertPara
.InsertPara
.Insert("Contents of the General Field:")
.InsertPara
.InsertPara
KEYBOARD "{ctrl+c} {ctrl+w}" && Copies and closes the general
&& field to the clipboard.
MODIFY GENERAL gen && This has to be after the
&& KEYBOARD command.
.EditPaste
.WordLeft(1,1)
.EditObject("0")
.EditSelectAll
.Editcopy
.FileClose
.EditClear
.EditPaste
.InsertPara
.InsertPara
.InsertPara
SKIP && Move the record pointer to
&& the next record.
ENDDO
.FileSaveAs("c:\mydoc.doc") && Saves the Word document as
&& Mydoc.doc.
.FilePrint
.AppClose
ENDWITH