Microsoft has awarded Lene Fredborg, DocTools, the Microsoft MVP award for Word each year since 2008. Link to info about the MVP Award at DocTools - document automation - add-ins, macros and document templates for Microsoft Word (logo) Document Automation
Add-ins & Macros
Document Templates
For Microsoft Word
Document automation, templates, add-ins, macros, for Microsoft Word (graphic)

Bookmark this page | Tip a friend about DocTools


Custom Search

Word document including macros ready for use...

Macro – Create List of Local Built-in Style Names

If you are creating a Word document, a template or an add-in that is going to be used on PCs with different language versions of Microsoft Word installed, you need to pay attention to the fact that the names of the built-in styles are language-specific. This article discusses some of the problems that may occur. In addition, you can download a Word document that lets you create a list of the local built-in style names with the click of a button.

Terms of use

You are welcome to use the macros and Word tips provided on this website. The contents is copyright. You may not reproduce any of contents (with or without modification or credits) elsewhere on the web, or on CD. Please link to the contents on this website instead.

Please note that all free Word tips, macros, add-ins and demos are provided "as is" and without obligation. See also detailed Terms of use.

Problems with language-specific built-in style names

Problems in relation to STYLEREF fields

STYLEREF fields are often used to repeat e.g. document headings in the document header. This is a great feature. The syntax of the field code is:

{ STYLEREF "name of style" }

See the article STYLEREF fields and language-specific style names for information about the problems that can occur in relation to STYLEREF fields when different language versions of Word are involved and for tips on how you can overcome the problems.

Note that the article linked above explains how you can use alias style names in STYLEREF fields. You can also use alias style names in macros.

Problems in relation to macros

In macros, you may often need code that applies a style or manipulates a style. If you insert the name as a string as shown in the following example, the macro will result in an error if it is executed on a PC with a non-English version of Word installed:

ActiveDocument.Styles("Heading 2").Font.Size = 12

Fortunately, there is a solution to that problem. The WdBuiltInStyle enumeration provides constants for the built-in style names. However, Microsoft developers seem to have forgotten constant names for all new styles added in Word 2007 and 2010 (but as shown below, there is also a solution in that situation). In VBA, you should always use the style name constants or the corresponding numbers. This way, your code will be independent of the installed language version of Word. The code line above would then look as follows:

ActiveDocument.Styles(wdStyleHeading2).Font.Size = 12

In case you need one of the built-in styles for which a name constant is missing, you can use the number instead. Actually, you could also use the number even if a name constant is found but in order to make your code easier to read and understand, I suggest you use the name constants whenever found. All built-in styles have a unique number. All the numbers are negative. For example, "Heading 2" has number -3. This means that the following code line would give the same result as the code samples above:

ActiveDocument.Styles(-3).Font.Size = 12

About the Word document ready for download

In order to make it easy to create a list of the local built-in style names, I have created a Word document you can download via the link below. The document contains a pre-completed table that includes the following for each built-in style – a total of 267 styles are included:

  • The VBA style name constant (example: wdStyleBodyText)
  • The corresponding VBA style name number (example: -67)
  • The English style name (example: Body Text)
  • An empty cell for the local style name – automatically filled in when you click a button in the document (see below)

The document contains a couple of macros that can be executed via buttons in the document. Click one button and all local styles names will automatically be filled in. Another button lets you clear the local style names.

The illustration below shows the top of page 1 of the Word document including the instruction, the buttons and the top of the table:

Part of page 1 of the Word document with the style list

Follow the instructions in the document. Please note that you need to enable macros when you open the document in order to be able to use the functionality in the document. The macros have been tested in Word 2003 and Word 2007 but they should also work in Word 2000 and Word 2002.

If you do not have access to the language version of Word for which you want to retrieve the styles names, you may send a copy of the document to somebody who has that version installed and ask him/her to run the macro, save the document and return it to you.

The illustration below shows part of the table filled with Danish style names:

Part of page 1 of the Word document with the style list

Related information

Via the link below, you can download a PDF document that contains the style names of almost 140 built-in styles in English, Danish, German and French:

Word Style Names in English, Danish, German, French.

See also the article STYLEREF fields and language-specific style names.

Top of page

Back to Macros...

Copyright © 2006-2017 Lene Fredborg – DocTools ApS – all rights reserved | Microsoft Word Templates – add-ins – VBA macros | Save time and work more efficiently in Microsoft Word
Privacy policy | Terms of use | Cookies policy | Bookmark this page | Tip a friend | Links | Contact