Error 5848 “The style definition is empty”, or, why are there two Normal styles in my document?

What causes this error?

I can't find any reference from Microsoft to the cause of error 5848 "The style definition is empty.".

But I can identify at least one way in which this error occurs. This only seems to go wrong in Word 2010, both RTM and SP-1.

The Style object in Word has an old, deprecated, property named .Hidden. You can only see it in the Object Browser in the Word VBE if you choose to 'Show Hidden Members'.

Reading the .Hidden property causes no problems.

Setting the .Hidden property to True or False has no effect on the visibility of the style in question.

But setting the .Hidden property of any style to True causes Word to create a new, fake, half-broken duplicate Normal style in your document.

This code, for example. will create a half-baked duplicate Normal style:

'Do not use this! This creates a broken duplicate Normal style in your document.

ActiveDocument.Styles(wdStyleBodyText).Hidden = True

When is this likely to be a problem?

A half-baked duplicate Normal style is likely to be a problem if you want to cycle though all styles in your document.

You can read some properties of the problem-child Normal style:

  • .NameLocal
  • .Description
  • .Font
  • .Frame
  • .Shading
  • .Table

If you attempt to read any other property of this problem Normal style, Word throws error 5848 "The style definition is empty".

How to avoid the problem

Don't apply the .Hidden property to any style, ever.

How to get around the problem

If you're cycling through all the styles in a document, it may be wise to include some error trapping in case you run into a document with this problem.

If you need to access the real Normal style, and don't want to risk referring to the problem child, do so using Word's built-in enumerated constant (which is good practice anyway).

So, use this:

'This is safe
ActiveDocument.Styles(wdStyleNormal)

not this:

'This might not be safe
ActiveDocument.Styles("Normal")

How to get rid of the offending "Normal" style

I can't find a way to get rid of the half-baked problem child in the user interface. I can only find it listed in the Manage Styles dialog (Figure 1). If I try to delete the style from there, Word does nothing. Apparently Word can't distinguish between the real "Normal" and the fake "Normal".

Two styles named 'Normal' showing in the Manage Styles dialog

It seems that the only way to get rid of this style is in code. Word is so protective of the real "Normal" style that we have to re-name the fake to delete it. Something like this seems to work:

Sub DeleteDuplicateNormalStyle()

Dim sty As Word.Style
Dim nCounter As Long
Dim eStyleType As Word.WdStyleType

    For Each sty In ActiveDocument.Styles
        If sty.NameLocal = "Normal" Then

            On Error Resume Next
            eStyleType = sty.Type

            If Err.Number = 5848 Then
                sty.NameLocal = "DuplicateNormal"
                sty.Delete
                Exit For
            End If
        End If

    Next sty

End Sub