1
votes

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
1

1 Answers

4
votes

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