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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
GrahamSkanRetiredCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.