PDA

View Full Version : Solved: Delete style...if it exists in document



clhare
01-04-2008, 06:27 AM
I'm trying to delete a style that may or may not be in the document. Is there a way to check to see if the style exists and if so delete it without getting an error message if it doesn't?

Here's what I have so far, but I still get an error saying that it doesn't exist.

If ActiveDocument.Styles("MyStyle").InUse Then
ActiveDocument.Styles("MyStyle").Delete
End If

TonyJollans
01-04-2008, 07:12 AM
I don't think there's an easy way to check for existence but you could just try to delete it and ignore the error ..


On Error Resume Next
ActiveDocument.Styles("MyStyle").Delete
On Error GoTo 0

clhare
01-04-2008, 07:57 AM
Thank you!! It works great now!