Centrer un tableau dans word généré via Excel

Bonsoir à tous, une question, je genere un tableau et remplit ensuite des données dans ce tableau dans word.

Quel est le code pour centrer le tableau dans word ?

Merci d'avance pour votre aide.

With .Tables.Add(Range:=Rng, NumRows:=1, NumColumns:=4)

' ajuste la largeur des colonnes

.HorizontalPosition = TableCenter

.Columns.Item(1).Width = WordApp.CentimetersToPoints(3)

.Columns.Item(2).Width = WordApp.CentimetersToPoints(3)

.Columns.Item(3).Width = WordApp.CentimetersToPoints(3)

.Columns.Item(4).Width = WordApp.CentimetersToPoints(3)

' .Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

' complète et formate les lignes de données

For i = 1 To 2

For j = 1 To 4

With .cell(i, j)

.Range.Font.Name = "Times New Roman"

.Range.Font.Size = 10

.Range.Text = ActiveSheet.Cells(300, j).Text

.Range.Font.Bold = False

.Borders.Enable = False

End With

Next j

' aligne les données

.cell(i, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

.cell(i, 2).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

.cell(i, 3).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

.cell(i, 4).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

Next

End With

Bonjour,

Eh thèorie cela devrait fonctionner :

With .Tables.Add(Range:=Rng, NumRows:=1, NumColumns:=4)

' ajuste la largeur des colonnes

.HorizontalPosition = TableCenter

.Columns.Item(1).Width = WordApp.CentimetersToPoints(3)

.Columns.Item(2).Width = WordApp.CentimetersToPoints(3)

.Columns.Item(3).Width = WordApp.CentimetersToPoints(3)

.Columns.Item(4).Width = WordApp.CentimetersToPoints(3)

' .Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

' complète et formate les lignes de données

For i = 1 To 2

For j = 1 To 4

With .cell(i, j)

.Range.Font.Name = "Times New Roman"

.Range.Font.Size = 10

.Range.Text = ActiveSheet.Cells(300, j).Text

.Range.Font.Bold = False

.Borders.Enable = False

End With

Next j

' aligne les données

.cell(i, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

.cell(i, 2).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

.cell(i, 3).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

.cell(i, 4).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter

' aligner la table
.Rows.Alignment = wdAlignRowCenter

Next

End With

Bonjour,

merci pour votre retour.

Malheureusement non il ne centre pas les tableaux par rapport aux centres de la feuille et je ne comprends pas pourquoi.

avez vous essayé, première ligne,

.Rows.HorizontalPosition = TableCenter

En efet je lis dans l'aide en ligne que l'objet table ne dispose pas directement de cette propriété, seulement ses lignes.

Super, merci beaucoup

Rechercher des sujets similaires à "centrer tableau word genere via"