Using Macros to Customize Bookmark Display

DB Precision allows for the insertion of tables by inserting a Word Bookmark into a document and then referencing that Bookmark within a plan's Export Definition.

Within DB Precision, users have options for customizing table display. However, for additional cusomization, macros can be used.

However, if that export is run and not stored in the archive, the macro will only be run once for the first participant (when the document is opened) and not run again. While this is fine when running an export for an individual, it can be a problem when running an export for a group (such as when running benefit statements).

To have Word run a macro separately for each record, the following must be done:

Referencing the Bookmark's Table

In order to manipulate a table's display, a user must first be able to reference the Bookmark's table. For a bookmark named "MyBookmark", the following could be used:

ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1)

Table Manipulation Examples

With the table referenced, user's can manipulate different components of the tables. The following are examples of different formatting options:

  • Resize Column 2:
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Columns(2).SetWidth ColumnWidth:=130, RulerStyle:=wdAdjustFirstColumn
  • Insert Custom Table Header:
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows(1).Select
    Selection.InsertRowsAbove(1)
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows(1).Cells.Merge
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows(1).Range.InsertBefore ("My Header Text")
  • Override Table Font Size:
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Range.Font.Size = 11
  • Override Header Row Font Size:
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows(1).Range.Font.Size = 14
  • Unbold Row 2:
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows(2).Range.Bold = False
  • Remove Row 2 Shading:
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows(2).Shading.Texture = wdTextureNone
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows(2).Shading.ForegroundPatternColor = wdColorAutomatic
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows(2).Shading.BackgroundPatternColor = wdColorAutomatic
  • Center Table on Page:
    ActiveDocument.Bookmarks("MyBookmark").Range.Tables(1).Rows.Alignment = wdAlignRowCenter
Prior Next


PensionSoft Corporation | 860.540.3690 | support@pensionsoft.com