Reputation: 11
My goal is to go to the top of the Word document, find the 6th table, and format the table to "Arial" and font 9 and distribute the column width.
The problem is that it doesn't distribute the column width but does the other two.
Sub TableFormat()
Selection.GoTo wdGoToPage, wdGoToAbsolute, 1
Selection.GoTo What:=wdGoToTable, Which:=GoToNext
Selection.GoTo What:=wdGoToTable, Which:=GoToNext
Selection.GoTo What:=wdGoToTable, Which:=GoToNext
Selection.GoTo What:=wdGoToTable, Which:=GoToNext
Selection.GoTo What:=wdGoToTable, Which:=GoToNext
Selection.GoTo What:=wdGoToTable, Which:=GoToNext
Selection.Tables(1).Select
Selection.Font.Name = "Arial"
Selection.Font.Size = 9
If Selection.Cells.Count >= 2 Then
Selection.Cells.DistributeWidth
End If
End Sub
Upvotes: 0
Views: 852
Reputation: 3261
This should do the trick for you without all that crazy Select
ing :)
Sub TableFormat()
With ActiveDocument.Tables(6)
With .Range.Font
.Name = "Arial"
.Size = 9
End With
If .Columns.count > 1 Then .Columns.DistributeWidth
End With
End Sub
Upvotes: 5