Author-it: Change table heading shading in Word

September 4, 2008

If you have added heading shading to tables in your Author-it topics, but want a different colored shading in the Word output, you can add an AfterPublish macro to your Author-it Word template to make this change automatically.

For example: Let’s say you used a green shading for all your table headings in Author-it. Maybe you did this because it was an easy way to distinguish the heading from the rest of the table, or perhaps the corporate branding required it. But now you’ve been asked to make all the table headings gray in the Word output. You have a couple of choices:

  1. Find EVERY table in Author-it and manually change the table heading shading. Not a viable option in the short term, and a painful process even in the long term.
  2. Use an AfterPublish macro to make the change at the time of publishing.

But what if you’re reusing these tables across various customer or product documentation? You may still need the green for Customer A but need gray for Customer B or blue for Customer C, etc. For this scenario, Option 1 is no longer an alternative—you have to use Option 2. At least until Author-it has a different way of styling the table properties.

The AfterPublish macro below finds all tables with a particular color in the heading and replaces that color with another color. You can use RGB values as shown here: mycell.Shading.BackgroundPatternColor = RGB(204, 230, 221)

or Word’s color values, e.g.
mycell.Shading.BackgroundPatternColor = wdColorLightOrange

NOTE: The underscores at the end of a line indicate that this line continues to the next; these break indicators are there for display purposes only.

Sub TableHeadingShading()
'Changes the background colour of a table cell _
colored with the first RGB value

Dim mytable As Table
Dim myrow As Row
Dim mycell As Cell

For Each mytable In ActiveDocument.Tables
For Each myrow In mytable.Rows
For Each mycell In myrow.Cells
If mycell.Shading.BackgroundPatternColor = _
RGB(229, 255, 209) _
Then mycell.Shading.BackgroundPatternColor = _
RGB(204, 230, 221)
End If

Next mycell
Next myrow
Next mytable

End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: