Supportnet / Forum / Textverarbeitung
Word-Makro Tabelleneigenschaften
Frage
Hallo Forum,
wie kann ich per Word-Makro Tabelleneigenschaften ändern? Ich habe eine Datei mit 126 Seiten und ca. 150 Tabellen, die aber alle unterschiedlich breit sind. Ich würde gerne alle auf 100% Breite setzen.
Vielen Dank!
Thomas
Antwort 1 von Thomas_3785
Hallo,
ich habe mal selber mit Aufzeichnen rumprobiert und bin mit dem Makro relativ weit gekommen. Allerdings bin ich bei Do ... loop nicht fit und habe deshalb die "Notlösung" mit dem Speichern gewählt und kicke Word dann. Allerdings funktioniert es komischerweise nicht bei allen Spalten.
Sub Makro1()
´
´ Tabellenbreite
´
Do
Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext, Count:=1, Name:=""
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Tables(1).Select
Selection.Tables(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Tables(1).PreferredWidth = CentimetersToPoints(19)
Selection.Tables(1).Rows.LeftIndent = CentimetersToPoints(0)
Selection.Rows.HeightRule = wdRowHeightAuto
Selection.Rows.Height = CentimetersToPoints(0)
Selection.Columns.PreferredWidthType = wdPreferredWidthAuto
Selection.Columns.PreferredWidth = 0
Selection.Cells.PreferredWidthType = wdPreferredWidthAuto
Selection.Cells.PreferredWidth = 0
Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
Selection.Rows.AllowBreakAcrossPages = False
With Selection.Font
.Name = "Arial"
.Size = 8
End With
ActiveDocument.Save
Loop
End Sub
ich habe mal selber mit Aufzeichnen rumprobiert und bin mit dem Makro relativ weit gekommen. Allerdings bin ich bei Do ... loop nicht fit und habe deshalb die "Notlösung" mit dem Speichern gewählt und kicke Word dann. Allerdings funktioniert es komischerweise nicht bei allen Spalten.
Sub Makro1()
´
´ Tabellenbreite
´
Do
Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext, Count:=1, Name:=""
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Tables(1).Select
Selection.Tables(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Tables(1).PreferredWidth = CentimetersToPoints(19)
Selection.Tables(1).Rows.LeftIndent = CentimetersToPoints(0)
Selection.Rows.HeightRule = wdRowHeightAuto
Selection.Rows.Height = CentimetersToPoints(0)
Selection.Columns.PreferredWidthType = wdPreferredWidthAuto
Selection.Columns.PreferredWidth = 0
Selection.Cells.PreferredWidthType = wdPreferredWidthAuto
Selection.Cells.PreferredWidth = 0
Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
Selection.Rows.AllowBreakAcrossPages = False
With Selection.Font
.Name = "Arial"
.Size = 8
End With
ActiveDocument.Save
Loop
End Sub