PDA

View Full Version : Table formatting macro in Word 2007



JRobinson22
01-20-2013, 09:45 AM
Hi - I have a very simple macro to select all tables in long documents and consistently format them (see below). I'm trying to add a line of code to this which will also indent all tables by 1/2 inch. Can anyone assist with this? Thanks!

Sub TableX()
'
' TableX Macro
'
'
Dim oTb As Table
For Each oTb In ActiveDocument.Tables

oTb.Style = "Table Elegant"
oTb.AutoFitBehavior (wdAutoFitWindow)


Next oTb
End Sub

gmaxey
01-20-2013, 04:47 PM
Does your table extend margin to margin? You might have to resize the table:

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTb As Table
For Each oTb In ActiveDocument.Tables
With oTb
.Style = "Table Elegant"
.AutoFitBehavior (wdAutoFitWindow)
.Rows.LeftIndent = InchesToPoints(0.5)
End With
Next oTb
End Sub