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

ID: Q126089

5.00 WINDOWS kbother xlwin

The information in this article applies to:

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

Keywords          : xlwin 
Version           : 5.00
Platform          : WINDOWS

Last Reviewed: November 18, 1998