Deleting user-defined paragraph styles that have got "_Diss" at theend of style name

A

andreas

Dear Experts:

I'd like to delete all custom-defined paragraph styles in a document.
All these user defined paragraph styles have the following syntax
(*_Diss). How can I delete all theses styles in one go using Word VBA.

Help is appreciated. Thank you very much in advance.

Regards, Andreas
 
J

Jay Freedman

Dear Experts:

I'd like to delete all custom-defined paragraph styles in a document.
All these user defined paragraph styles have the following syntax
(*_Diss). How can I delete all theses styles in one go using Word VBA.

Help is appreciated. Thank you very much in advance.

Regards, Andreas

Sub Delete_Diss()
Dim myStyle As Style
For Each myStyle In ActiveDocument.Styles
If LCase(Right(myStyle.NameLocal, 5)) = "_diss" Then
myStyle.Delete
End If
Next
End Sub

I prefer to use the LCase function to guard against possible differences in the
cases of the characters, for example, if the 'd' was upper case in some styles
but lower case in others.
 
A

andreas

Sub Delete_Diss()
    Dim myStyle As Style
    For Each myStyle In ActiveDocument.Styles
        If LCase(Right(myStyle.NameLocal, 5)) = "_diss" Then
            myStyle.Delete
        End If
    Next
End Sub

I prefer to use the LCase function to guard against possible differences in the
cases of the characters, for example, if the 'd' was upper case in some styles
but lower case in others.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.

Jay,

thank you very much. It is working fine.
Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top