Graham Mayor

... helping to ease the lives of Microsoft Word users.

Many people access the material from this web site daily. Most just take what they want and run. That's OK, provided they are not selling on the material as their own; however if your productivity gains from the material you have used, a donation from the money you have saved would help to ensure the continued availability of this resource. Click the appropriate button above to access PayPal.

Word VBA Built-in Style Enumeration

The add-in featured here is a programmer's aid to resolving the enumeration and the constant name of Word's built-in styles in the form of a simple userform dialog from which the style can be selected and the enumeration or constant name can be copied to the clipboard.

The requirement is based on the issue of using local style names in VBA code when programming for users in different countries. For example, the English local style name 'Body Text' is 'Textkörper' in German and 'Corps de texte' in French. Using the English local name will thus cause problems for users of different languages.

The add-in adds a button group and a single button to the Add-ins tab of the Word ribbon:

The add-in works in conjunction with a simple Excel workbook which is saved in the same folder as the add-in template.

Following my usual disclaimer dialog, the worksheet is read into the list box of the userform, which displays all the available built-in styles.

As there are a lot of built-in styles, the list can be limited by initial letter using the button pad alongside the list.

However some letters do not match the first letter of a style and the lost is empty

Select a style and the enumeration for that style and its constant name are displayed.

Depending on the setting of the radio buttons below the last, either the enumeration or the constant name will be copied to the clipboard

Note that not all the built-in styles have a constant name. Where this occurs, the constant name is shown as missing and nothing is coped to the clipboard

Click the large button at the foot of the dialog to close the dialog and copy the selecvtion to the clipboard as appropriate. Preferences are retained between uses.

- Click here to download the add-in


 Style Enumeration

When programming for different language versions of Word, the fact that the local names of Word's built-in styles can vary with country, it is therefore preferable to use the Style enumeration or constant name, rather than the local name, to avoid unnecessary errors.