The Macro Zone

VBA in Microsoft Word for Windows

Jay Freedman  Microsoft Most Valuable Professional

Captions with Chapter Numbers from a Custom Style

You can add captions to figures, tables, and equations in a Word document. If the document contains multiple chapters, you can choose to add the chapter number to the caption number as in “Figure 3-1”. The article Add chapter numbers to captions in Word describes the standard procedure.

The Caption dialog makes you specify the style used for chapter headings throughout the document, and it lists the nine built-in Heading styles to choose from. What if you want to define a custom style and use that for the chapter numbers, keeping the built-in Heading styles for other purposes?

It’s much better to use the built-in Heading styles, with modified formatting if necessary, as explained in the article Why use Microsoft Word’s built-in heading styles? If your document is already set up with a custom style, though, this page is here to help you.

The add-in that you can download from the link at the end of this page makes the captions work with any numbered style that you use for chapter headings, either built-in or custom. The add-in works with all Word versions from 2007 through 2016.

Installing the Add-In

After downloading the zip file to your local drive, extract the contents (a macro-enabled template named Custom Style Chapter Numbering Captions.dotm) into the folder %appdata%\Microsoft\Word\Startup. If Word was already running, restart it.

The add-in loads when Word starts, and it places a yellow happy-face icon on the Quick Access Toolbar.

Preparing the Document

Define your custom chapter heading style with your preferred formatting. In its Paragraph properties, set its Outline Level to “Level 1”.

Dialog box named Modify Style and one named Paragraph

Set up the heading styles and a list style as described in the article How to create numbered headings, but assign your custom style to the Level 1 numbering.

Dialog box named Define New MultiLevel List

Inserting Captions

Use the standard method of inserting captions with chapter numbers, as shown in the article Add chapter numbers to captions in Word. Choose Heading 1 as the chapter heading style to use in the caption; later, the add-in will change the captions.

If your document doesn’t have any paragraphs in Heading 1 style, the captions you insert will temporarily show “Error! No text of specified style in document” in place of the chapter number. If you do have at least one paragraph in Heading 1 style, the chapter number will temporarily show as zero.

Running the Add-In

Click the yellow happy-face icon on the Quick Access Toolbar. A dialog box opens to let you select the custom style for the chapter numbers:

Dialog box named Select Custom Style

Be sure to choose the numbered style and not the list style with which it’s associated. Then click the OK button.

In a large document with many figures and tables, the add-in may take a few minutes to finish.

After you run the add-in, if you add more captions to the document, all the existing captions will return to trying to use Heading 1 as the chapter number style. Run the add-in again to fix the numbering.

Obtaining the Add-In

Click this link to download the add-in as a zip file: Custom Style Chapter Numbering