Selecting and Formatting First Row of Every Table Within a Document

Teresa Howell
Teresa Howell used Ask the Experts™
I am working with a large MS Word file (hundreds of pages).  It contains many, many tables.  I would like to select the first row of every table, make the font 8 point Times New Roman, and center the text within the first row.  I found a solution that accomplishes everything but center the text of the row.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
NorieAnalyst Assistant


This will set the horizontal alignment of all the cells in the first row of all the tables in the active document to Center.
Dim tbl As Table
Dim rw As Row
Dim cl As Cell

    For Each tbl In ActiveDocument.Tables
        Set rw = tbl.Rows(1)
        For Each cl In rw.Cells
            cl.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
        Next cl
    Next tbl

Open in new window

If you also want to set the vertical alignment you can add this to the loop.
            cl.VerticalAlignment = wdCellAlignVerticalCenter

Open in new window


Thank you, Norie!  It worked perfectly for me and was just what I needed.  I couldn't be happier.  You've saved me hours upon hours of work.  This is fantastic.  

Thank you, again.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial