Repeat header rows for all tables in active document

Posted on 2012-08-17
Last Modified: 2012-08-17
Dear Experts:

For ALL the TABLES in the active document I would like to perform the following action:

Repeat the header row if the table spans more than one page
Apply grey shading to all the header rows
Apply font name Arial and font size 9 pt to all the header rows.

Help is much appreciated.

Thank you very much in advance.

Regards Andreas
Question by:AndreasHermle
    LVL 76

    Accepted Solution

    Hi Andreas, I'm sure that you could have written this one yourself:
    Sub SetTableHeaders()
        Dim tbl As Table
        For Each tbl In ActiveDocument.Tables
            With tbl.Rows.First
                .Range.Font.Name = "Arial"
                .Range.Font.Size = 9
                .Shading.BackgroundPatternColor = wdColorGray30
                .HeadingFormat = True
            End With
        Next tbl
    End Sub

    Open in new window

    LVL 59

    Assisted Solution

    by:Chris Bottomley

    Sub headerAH()
    Dim tbl As Table
        For Each tbl In ActiveDocument.Tables
            With tbl.Rows(1)
                .HeadingFormat = True
                .Shading.Texture = wdTextureNone
                .Shading.ForegroundPatternColor = wdColorAutomatic
                .Shading.BackgroundPatternColor = wdColorGray10
                .Range.Font.Name = "Arial"
                .Range.Font.Size = 9
            End With
    End Sub

    Open in new window


    Author Closing Comment

    Both codes are practically the same with Graham having posted less than a minute earlier. Therefore I suggest splitting the points. I guess you can live with that.

    Graham: you are right, with the hundreds of code snippets I have gotten from you and other experts I am able to write dozens and dozens of macros myself successfully. I was not quite sure about this 'HeadingFormat' and therefore hat it commissioned.

    Thank you very much for your great support. I really appreciate it.

    Regards, Andreas

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
    This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
    This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
    This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now