Réponse acceptée !
je le rouve en fin
#DEFINE wdToggle 9999998 #DEFINE wdTableRight -999996 #DEFINE wdAlignParagraphLeft 0 #DEFINE wdAlignParagraphCenter 1 #DEFINE wdAlignParagraphJustify 3 #DEFINE wdHorizontalPositionMargin 0 #DEFINE wdCollapseEnd 0 #DEFINE wdCollapseStart 1 #DEFINE wdParagraph 4
oWord = CREATEOBJECT("Word.Application") oWord.Visible = .F. && Toggle this to True to see if there's && any difference oDoc = oWord.Documents.Add() oRange = oDoc.Range() oRange.Collapse(wdCollapseStart) *!* WITH oRange *!* .ParagraphFormat.Alignment = wdAlignParagraphCenter *!* .Font.Size = 14 *!* .Font.Name = "Arial Black" *!* .InsertAfter("Heading for Sales Report") *!* .MoveEnd(wdParagraph,1)
*!* .Bold = .T. *!* .Collapse(wdCollapseEnd) *!* .InsertParagraphAfter() *!* .MoveEnd(wdParagraph,1) *!* .Bold = .F. *!* .Collapse(wdCollapseEnd)
*!* .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
|