Code : Tout sélectionner
#include "WordConstants.au3"
$nom = "toto"
$word = ObjCreate("Word.Application")
$word.visible = True
$word.Documents.Add
$wordopen = $word.ActiveDocument
$bb = $wordopen.content
$matable = $wordopen.Tables.Add($bb, 3, 3,Default,Default)
For $i = 1 To 3
For $y = 1 To 3
$matable.Cell($i,$y).Range.InsertAfter ($i & $y)
$matable.Cell($i,$y).Select
$word.Selection.Cells.VerticalAlignment = $wdCellAlignVerticalCenter
$word.Selection.ParagraphFormat.Alignment = $wdAlignParagraphCenter
With $word.Selection.Cells.Borders($wdBorderLeft)
.LineStyle = $wdLineStyleSingle
.LineWidth = $wdLineWidth300pt
.Color = $wdColorWhite
EndWith
With $word.Selection.Cells.Borders($wdBorderRight)
.LineStyle = $wdLineStyleSingle
.LineWidth = $wdLineWidth300pt
.Color = $wdColorOliveGreen
EndWith
With $word.Selection.Cells.Borders($wdBorderTop)
.LineStyle = $wdLineStyleSingle
.LineWidth = $wdLineWidth300pt
.Color = $wdColorOrange
EndWith
With $word.Selection.Cells.Borders($wdBorderBottom)
.LineStyle = $wdLineStyleSingle
.LineWidth = $wdLineWidth300pt
.Color = $wdColorDarkBlue
EndWith
Next
$wordopen.Tables(1).Rows(1).Cells($i).Shading.Texture = $wdTexture20Percent
$wordopen.Tables(1).Rows(2).Cells($i).Shading.BackgroundPatternColor= $wdColorGold
$wordopen.Tables(1).Rows(3).Cells($i).Shading.Texture = $wdTextureDiagonalDown
Next
MsgBox(64,"","Tableau formatté",3)
$matable.Cell(3,3).Select
$word.Selection.InsertCells ($wdInsertCellsShiftRight)
MsgBox(64,"","Nouvelle Cell",3)
$wordopen.Tables(1).Cell(3, 4).Delete
MsgBox(64,"","Cell détruite",3)
$wordopen.Tables(1).ConvertToText ($wdSeparateByTabs)
MsgBox(64,"","Tableau en texte",3)
$debut = $wordopen.Paragraphs(1).Range.Start
$fin = $wordopen.Paragraphs(3).Range.End
$wordopen.Range($debut,$fin).Select
$matable = $word.Selection.ConvertToTable($wdSeparateByTabs,Default,Default,100,$wdTableFormatColorful1, _
Default,Default,Default,Default,Default,Default,Default,Default,True,$wdWord9TableBehavior,$wdAutoFitFixed)
MsgBox(64,"","texte en tableau",3)
$matable.Cell(3, 3).AutoSum
$matable.Cell(3,3).Select
$xx = $word.Selection.Text
$wordopen.Range.insertAfter("somme C1 + C2 = " & $xx)
$wordopen.Range.insertAfter("FINI...." )
$wordopen.Range.insertAfter($nom )