Unusual style names appear in the Styles and Formatting list in Word (839646)



The information in this article applies to:

  • Microsoft Office Word 2003
  • Microsoft Word 2002
  • Microsoft Word 2000

SYMPTOMS

When you click Styles and Formatting on the Format menu to view your styles list in Microsoft Office Word 2003, you may notice that unusual style names are listed.

For example, the last saved on, the last printed by, or the create date style names may appear in the Styles and Formatting list although they are not part of your document.

CAUSE

This issue may occur when you create AutoText entries that contain large blocks of text.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To remove these unusual styles names from the Styles and Formatting list, create and then run the following Microsoft Visual Basic for Applications (VBA) macro.

Note The following sample macro may also remove custom styles that are listed as being available but are not being used in the document.
Sub CleanStyles()

   On Error Resume Next

   Dim st As Style

   For Each st In ActiveDocument.Styles

      If st.InUse Then
         With ActiveDocument.Range.Find
            .ClearFormatting
            .Style = st.NameLocal
   
               If .Execute(Format:=True, Wrap:=wdFindStop) = False Then
                  st.Delete
               End If

         End With
      End If

   Next

End Sub

Modification Type:MajorLast Reviewed:3/23/2006
Keywords:kbprb KB839646 kbAudEndUser