Page 1 sur 1
[Ex] Word Table Constants
Posté : dim. 01 déc. 2013 17:02
par walkson
Bonjour,
Ce que je propose, n'est pas un exemple à proprement parlé, mais un ensemble de constants Word 2007 adapté à Autoit pour le formatage de tableau (orienté dans ce sens).
Voici un exemple:
► Afficher le texte
Code : Tout sélectionner
#include <WordTableConstants.au3>
$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...." )
Je n'ai rien trouvé de semblable sur Internet donc je pense qu'il pourrait être utile à quelques uns.
Je pense aussi avoir fait le tour du sujet concernant le formatage des tableaux Word même si certaines fonctions interfèrent avec d'autres éléments ou objets.
Merci de me signaler des oublis.
Re: [Ex] Word Table Constants
Posté : jeu. 05 déc. 2013 16:48
par scorp84
Bonjour walkson,
Merci pour ce partage qui va grandement m'aider
Amicalement.
BM
Re: [Ex] Word Table Constants
Posté : jeu. 05 déc. 2013 22:41
par mikell
Faudrait mettre un #include<WordConstants.au3> et supprimer les doublons, pour éviter les erreurs de double déclaration de constantes
Teste juste ces 2 lignes dans un .au3
Code : Tout sélectionner
#include <WordConstants.au3>
#include "WordTableConstants.au3"
Re: [Ex] Word Table Constants
Posté : mer. 11 déc. 2013 14:19
par walkson
Bonjour,
Problème de surveillance du sujet fait d'être en retard pour répondre.
Tout d'abord, j'ai des progrès à faire dans mes recherches....
Suite au message de Mikell, j'ai regardé les includes sans trouver <WordConstants.au3>. Une recherche sur mon PC m'a trouvé cet include de Water que j'avais rajouté manuellement et qui reste limité avec 175 lignes.
Par contre, sur
http://www.autoitscript.com, j'ai trouvé <WordConstants.au3> de RealShyfox à cette adresse
http://www.autoitscript.com/forum/topic ... tants-udf/ comprenant 3018 lignes et qui semble être complet.
Après vérification, toutes les constants que j'ai proposés, sont comprises dans ce dernier plus, bien sur, beaucoup d'autres. Donc, je conseille fortement de télécharger l'include de RealShyfox.
J'avoue, après avoir fait des recherches sur msdn.microsoft.com tant pour Word que pour Excel, c'est le B....L avec les différentes versions Office et tout le reste.