• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1252
  • Last Modified:

Repeat header rows for all tables in active document

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
0
AndreasHermle
Asked:
AndreasHermle
2 Solutions
 
GrahamSkanCommented:
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

0
 
Chris BottomleyCommented:
Try:

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
    Next

End Sub

Open in new window


Chris
0
 
AndreasHermleAuthor Commented:
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now