Reputation: 843
I have a word document with a lot of tables. I would like a macro which changes the fonts size of all tables to 10, autofits each table to the window and distributes the columns evenly. I can accomplish the last two goals using the below code, but not sure how to change the font size. Any help would be greatly appreciated.
Sub changetables()
Dim tbl As Table
For Each tbl In ActiveDocument.Tables
tbl.AutoFitBehavior wdAutoFitWindow
tbl.Columns.DistributeWidth
Next
End Sub
Upvotes: 1
Views: 11747
Reputation: 1
Just change .size to .name, as in tbl.Range.Font.Name = "Calibri"
This should also work for whatever font name you wish to use by replacing Calibri within the double quotes to your desired font name.
Upvotes: 0
Reputation: 2693
For your exact code use
tbl.Range.Font.Size = 12
I have retyped a few things to show better naming and spacing etc.
Sub changetables()
Dim CurrentTable As Table
For Each CurrentTable In ActiveDocument.Tables
With CurrentTable
.AutoFitBehavior wdAutoFitWindow
.Columns.DistributeWidth
.Range.Font.Size = 12
End With
Next CurrentTable
End Sub
Upvotes: 4