Table Captions automate Centre All Tables

P

PeterJ

Back again,

Looking to centre ALL inline Tables/Figures in my document? Is that
possible - on a deadline (every time save helps).
 
S

Stefan Blom

This very simple macro should work:

Sub AlignmentTest()
Dim i As InlineShape
Dim t As Table
For Each i In ActiveDocument.InlineShapes
i.Range.Paragraphs(1).Alignment = wdAlignParagraphCenter

Next i

For Each t In ActiveDocument.Tables
t.Rows.Alignment = wdAlignRowCenter

Next t
End Sub

But note that the macro does *not* adjust the positions of any table or
figure captions accompanying the tables and figures.

--
Stefan Blom
Microsoft Word MVP


in message news:%[email protected]...
 
P

PeterJ

Stefan, thank you, shall try it now! You guys are very helpful in my hour of
need!
 
P

PeterJ

Stefan, how do I incorporate

With Selection.Tables(1)
.TopPadding = InchesToPoints(0)
.BottomPadding = InchesToPoints(0)
.LeftPadding = InchesToPoints(0)
.RightPadding = InchesToPoints(0)
.Spacing = 0
.AllowPageBreaks = False
.AllowAutoFit = False
End With
in top part of macro?


Sub Alignment()

'But note that the macro does *not* adjust the positions of any table or
'figure captions accompanying the tables and figures.

Dim i As InlineShape
Dim t As Table
For Each i In ActiveDocument.InlineShapes
i.Range.Paragraphs(1).Alignment = wdAlignParagraphCenter

Next i

For Each t In ActiveDocument.Tables
t.Rows.Alignment = wdAlignRowCenter
t.Rows.WrapAroundText = False
t.Rows.HorizontalPosition = wdTableCenter
t.Rows.RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
t.Rows.DistanceLeft = InchesToPoints(0)
t.Rows.DistanceRight = InchesToPoints(0)
t.Rows.VerticalPosition = InchesToPoints(0)
t.Rows.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
t.Rows.DistanceTop = InchesToPoints(0.6)
t.Rows.DistanceBottom = InchesToPoints(0.2)
t.Rows.AllowOverlap = True

Next t
End Sub
 
S

Stefan Blom

You can use

With t
.TopPadding = InchesToPoints(0)
.BottomPadding = InchesToPoints(0)
.LeftPadding = InchesToPoints(0)
.RightPadding = InchesToPoints(0)
.Spacing = 0
.AllowPageBreaks = False
.AllowAutoFit = False
End With

instead of With Selection.Tables(1)... End With. Of course, this assumes
that the code is inside For Each t In ActiveDocument.Tables... Next t.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top