Microsoft KB Archive/224017

= WD2000: Err Msg: "Run-time error '5122': This style name does not exist." =

Article ID: 224017

Article Last Modified on 12/2/2005

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q224017



ERROR MESSAGE
When you try to delete a style from a document with the use of a Visual Basic for Applications macro, the following error message may appear:

Run-time error '5122':

This style name does not exist.

For example, when you run the following sample macro code to delete the style "BodyTextIndent", the error message may appear.

Sub DeleteBuiltInStyle

Dim odocStyle As Styles Set odocStyle = ActiveDocument.Styles

odocStyles(wdStyleBodyTextIndent).Delete

End Sub NOTE: Microsoft Office 2000 has built-in functionality that allows you to get more information about difficult-to-troubleshoot alerts or error messages. If you want to enable this functionality for this and other error messages in Microsoft Office 2000, please download the Microsoft Office 2000 Customizable Alerts file from the Microsoft Office Update Web site at the following address:

http://www.microsoft.com/downloads/details.aspx?FamilyID=8FBEE1D3-C5BB-4A36-A2F7-DC63DE2A818C

NOTE: If you reached this article by clicking the Web Info button in an error message, you already have Customizable Alerts enabled.



The style you are trying to delete does not exist in the document.
To avoid receiving the error message when you delete a style from a document, you must first verify that the style has been used in the document.

The following sample Visual Basic for Applications macro determines whether the style (Body Text Indent) is being used in the document and, if it is used, it removes the style. If the style does not exist in the document, no message is displayed. Sub DeleteBuiltInStyle Dim odocStyle As Styles Set odocStyle = ActiveDocument.Styles

If odocStyle(wdStyleBodyTextIndent).InUse Then odocStyle(wdStyleBodyTextIndent).Delete End If

End Sub 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.

For additional information about deleting unused styles, please see the following articles in the Microsoft Knowledge Base:

189297 WD2000: Sample VBA Code to Delete Built-In Style

193536 WD2000: How to Remove Unused Standard Styles from Document

Additional query words: OFF2000

Keywords: kbprb KB224017

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.