How do I apply the same formatting to multiple tables in a Word document

I have a big Word doc containing a bunch of tables that all need to have the same column width.  Is there a way for me to apply the same column width to all the tables simultaneously?  This should be an easy one for any Word gurus out there!
LVL 2
etd_onlineguysAsked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
This will do each column separately
Sub ColWidths()
    Dim wdTable As Table
    For Each wdTable In ActiveDocument.Tables
        With wdTable
            .AllowAutoFit = False
            .Columns(1).Width = CentimetersToPoints(3.5)
            .Columns(2).Width = CentimetersToPoints(2.5)
            .Columns(3).Width = CentimetersToPoints(1.5)
        End With
    Next wdTable
End Sub

Open in new window

0
 
GrahamSkanRetiredCommented:
The snippet is a VBA macro to set all the column widths of all the tables to 2 centimetres.


Sub ColWidths()
    Dim wdTable As Table
    For Each wdTable In ActiveDocument.Tables
        With wdTable
            .AllowAutoFit = False
            .Columns.Width = CentimetersToPoints(2)
        End With
    Next wdTable
End Sub

Open in new window

0
 
etd_onlineguysAuthor Commented:
Thanks for the comment.  The tables I'm formatting have 3 columns.  How would I format all 3 to different widths?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
GrahamSkanRetiredCommented:
That was quick!
0
 
GrahamSkanRetiredCommented:
"That was quick!"

I clicked on Proposed Solution in error and the colouration is similar to 'Accepted' so I thought you had magically acceptd the answer in seconds.
0
 
etd_onlineguysAuthor Commented:
Great solution!  Thanks for your help.
0
All Courses

From novice to tech pro — start learning today.