online 1
gast (50)

/ Forum / Textverarbeitung

TextverarbeitungTextverarbeitung

Fragevon FWagner vom 22.10.2020, 15:35 Options

Word Makro alle Tabellen Spaltenbreite vorgeben

Hallo,

ich habe einige Tabellen in Word die alle gleich formatiert werden sollen (breite spalte a = 3cm, spalte b = 1,13cm, usw..).

Jetzt habe ich es schon geschafft, ein Makro zu machen, das mir das mit der Tabelle macht die ich makiert habe. Mit folgendem VB-Code

Sub Tabelle()
'
' Tabelle Makro
' Makro aufgezeichnet am 21.10.2008 von fWagner
'
With Selection.Tables(1)
.TopPadding = CentimetersToPoints(0.08)
.BottomPadding = CentimetersToPoints(0.08)
.LeftPadding = CentimetersToPoints(0.08)
.RightPadding = CentimetersToPoints(0.08)
.Spacing = CentimetersToPoints(0)
.AllowPageBreaks = True
.AllowAutoFit = False
End With
Selection.Tables(1).Columns(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Tables(1).Columns(1).PreferredWidth = CentimetersToPoints(3)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(1.13)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(1.26)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(5.83)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(2.22)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(8.25)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(4.13)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(2.19)
End Sub

Meine Versuche mit DIMTable sind gescheitert, allderings kenne ich mich da auch nicht aus. Ich habe es mal hiermit versucht, funktioniert aber nicht:

Sub test3()
'
' test3 Makro
' Makro aufgezeichnet am 22.10.2008 von fWagner
'

Dim Tabelle As Table
For Each Tabelle In ActiveDocument.Tables


Tabelle.Columns(1).PreferredWidthType = wdPreferredWidthPoints
Tabelle.Columns(1).PreferredWidth = CentimetersToPoints(3)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(1.13)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(1.26)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(5.83)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(2.22)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(8.25)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(4.13)
Selection.Move Unit:=wdColumn, Count:=1
Selection.SelectColumn
Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
Selection.Columns.PreferredWidth = CentimetersToPoints(2.19)

Next Tabelle
End Sub


Kann mir jemand sagen, was ich falsch gemacht habe und wies Weiter geht, finde in allen Foren keine Antworten oder verstehe sie nicht.

Vielen Dank schonmal


Antwort schreiben

Antwort 1 von Lisa2004 vom 22.10.2020, 18:25 Options

Sub Tabelle()
Dim Tabelle As Word.Table
For Each Tabelle In ActiveDocument.Tables

    Tabelle.Columns(1).Width = CentimetersToPoints(3)
    Tabelle.Columns(2).Width = CentimetersToPoints(1.13)
    Tabelle.Columns(3).Width = CentimetersToPoints(1.26)
    Tabelle.Columns(4).Width = CentimetersToPoints(5.83)
    
    Tabelle.Columns(5).Width = CentimetersToPoints(2.22)
    Tabelle.Columns(6).Width = CentimetersToPoints(8.25)
    Tabelle.Columns(7).Width = CentimetersToPoints(4.13)
    Tabelle.Columns(8).Width = CentimetersToPoints(2.19)
    Next Tabelle

End Sub

wird das nicht zu breit? -dann anpassen.
Gruß Lisa

Ähnliche Themen

Word makro
Chrigel  12.08.2007 - 32 Hits - 3 Antworten

Makro in Office Word 2007?
Snoop07  04.10.2007 - 96 Hits - 1 Antwort

word 2003-dateien lassen sich in word 2007 nicht öffnen
meisenkaiser4711  20.12.2007 - 296 Hits - 2 Antworten

Word Makro zeitlich unterbrechen
Matty  11.02.2008 - 38 Hits - 1 Antwort

Hinweis

Diese Frage ist schon etwas älter, Sie können daher nicht mehr auf sie antworten. Sollte Ihre Frage noch nicht gelöst sein, stellen Sie einfach eine neue Frage im Forum..

Neue Einträge

Version: supportware 1.9.150 / 10.06.2022, Startzeit:Thu Jan 8 21:07:44 2026