Lene Fredborg, DocTools, har hvert år siden 2008 modtaget den prestigefyldte pris som Microsoft Most Valuable Professional (MVP) i Word – link til information om MVP Award'en DocTools - dokumentautomatisering - add-ins, makroer og skabeloner til Microsoft Word (logo) Dokumentautomatisering
Add-ins & Makroer
Til Microsoft Word
Dokumentautomatisering, skabeloner (templates), add-ins og makroer til Microsoft Word (grafik)

Søg thedoctools.com:

Custom Search

Word Tips about...

STYLEREF fields and language-specific style names

STYLEREF fields are often used to repeat e.g. document headings in the document header. This is a great feature. A STYLEREF field must refer to the name of a specific style. If your templates or documents are to be used on computers with different language versions of Word, you cannot simply refer to the name of a built-in style in a STYLEREF field since the style name will be different in another language version of Word. For example, the English style name "Heading 1" is "Overskrift 1" in a Danish version of Word. A STYLEREF field that refers to "Heading 1" will show an error code in non-English versions of Word. This article provides tips on how you can overcome this problem and create STYLEREF fields that will work correctly in any language version of Word.

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.

The field code of a STYLEREF field

The syntax of the field code in a STYLEREF field is:

{ STYLEREF "name of style" }

If, for example, you want to repeat Heading 1 in the header, the field code could look like this:

{ STYLEREF "Heading 1" }

How to prevent problems with STYLEREF fields to built-in heading styles across different language versions of Word

The STYLEREF field code above for "Heading 1" is OK if the document in question is used on a PC with an English language version of Word installed. But if you open the same document on a PC with another language version of Word, a problem occurs since "Heading 1" is no longer a correct style name. The style name is not found and the field will show an error, telling that the style does not exist.

In case of the heading styles, Heading 1, Heading 2, ... , Heading 9, you can prevent the problem by using only the heading level number instead of the full name:


The field code above will work in any language version. But you do not have the same option when it comes to other built-in styles. You will need to use the correct style names. See below for a way to work around that problem.

How to prevent problems with STYLEREF fields to other built-in styles across different language versions of Word


You want to use a STYLEREF field to repeat the title of a document. You have used the built-in style, "Title" for the title text. But in e.g. a Danish version of Word, that style is named "Titel".

Therefore, the field code { STYLEREF "Title" } will not work since "Title" is not the correct style name in other languages. Only the built-in heading styles have a number you can use instead of the full style name.

If you create a STYLEREF field using the English name "Title", { STYLEREF "Title" }, and open the document on a computer with a Danish version of Word, you will see error code (1) below. If you use the Danish style name in the STYLEREF field and open the document on a computer with an English version of Word, you will see error code (2) below.

A STYLEREF field shows and error if the specified style does not exist

Styles and alias names

The solution to the problem illustrated in the example above is to take advantage of alias names to styles.

Any style in Word, built-in or custom, can be given one or more alias names, i.e. extra names that can be used together with or instead of the "main" name. The "main" name and alias name(s) must be separated by the list separator specified in Regional and Language > Additional settings. In US the default list separator is a semicolon, in e.g. Denmark the default list separator it is a comma.

Note that all style names in a document must be unique. This is true for alias style names too.

Now the trick: You can add an alias name to the built-in style name (in this example the style "Title"). You do so by specifying the alias name at the end of the existing name in the Modify Style dialog box, separating it from the existing name with the correct list separator.

In the illustration below, the style "Title" has been given an alias name "MyTitle". A semicolon separates the names:

A STYLEREF field shows and error if the specified style does not exist

To insert a STYLEREF field to the built-in style "Title", you can now use the alias name in the field code:

{ STYLEREF "MyTitle" }

It is important that the STYLEREF field refers to the alias name only.

Since the alias name is a custom name, it is a fixed name that will not change. This way that STYLEREF field will work correctly regardless of the language version of Word.

What you should also know about alias names to styles

A disadvantage of alias names is that they follow along if you copy text to another document and paste the text in a way the preserves styles. This way, you may end messing up style names in other documents.

You can assign keyboard shortcuts to styles. Short alias names can also be used as shortcuts for selecting styles. An alias name can consist of a single character only. For example, you could add "p" as an alias name for a style that is used very often and the style can be applied by pressing Ctrl+Shift+S to open or activate the Apply Styles window, then p, then Enter.

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 Macro – Create List of Local Built-in Style Names.

For more tips about STYLEREF fields, see also Useful StyleRef tricks.

Top of page

Back to Word Tips ...

BulletADD-INS Word add-ins ready for use - work smarter in Word

Copyright © 2006-2018 Lene Fredborg – DocTools ApS – alle rettigheder forbeholdt | Microsoft Word skabeloner (templates) – add-ins – VBA makroer | Spar tid og arbejd mere effektivt i Microsoft Word
Betingelser for brug | Persondatapolitik | Om cookies | Kontakt