XL5: Can't Delete Style Name That Ends with a Space Character

Last reviewed: September 12, 1996
Article ID: Q126089
The information in this article applies to:
  • Microsoft Excel for Windows, version 5.0

SYMPTOMS

In Microsoft Excel, if you use a Visual Basic procedure to create a style with a name that ends with a space character, such as "test ", you cannot delete this style. When you select the style in the Style dialog box, the Delete button is unavailable (dimmed).

If you run the following Visual Basic procedure to delete the style

   Sub DeleteStyle()
      ActiveWorkbook.Styles("test ").Delete
   End Sub

you do not receive an error message, but the style is not deleted.

CAUSE

This behavior occurs because when you use a Visual Basic procedure to create a new style, it is possible to add a style with a name that ends in a space character. This behavior is incorrect, and results in a style that you cannot delete.

When you enter a style with a name that ends with a space using the Style dialog box, the space is automatically removed from the style name when you choose Add. If you use the DEFINE.STYLE() function in an MS Excel 4.0 macro to add a style with a name that contains a space, the space is also automatically removed when the style is added.

WORKAROUND

To avoid this behavior when you create a style using a Visual Basic procedure, make sure that any style names that you add do not end with a space character.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel version 5.0c.

In Microsoft Excel version 5.0c, when you use a Visual Basic procedure to add a style, any spaces at the end of the style name are automatically removed when the style is added.

REFERENCES

For more information about Creating And Deleting A Style, choose the Search button in Help and type:

   styles


KBCategory: kbother
KBSubcategory: xlwin

Additional reference words: 5.00 grey gray



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.