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

Re: Deleting user-defined paragraph styles that have got "_Diss" at the end of style name by Jay

Jay
Sun May 04 19:01:11 PDT 2008

On Sun, 4 May 2008 14:49:17 -0700 (PDT), andreas <andreas.hermle@gmx.de> wrote:

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

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

Re: Deleting user-defined paragraph styles that have got "_Diss" at by andreas

andreas
Mon May 05 22:15:59 PDT 2008

On May 5, 4:01=A0am, Jay Freedman <jay.freed...@verizon.net> wrote:
> On Sun, 4 May 2008 14:49:17 -0700 (PDT), andreas <andreas.her...@gmx.de> w=
rote:
> >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()
> =A0 =A0 Dim myStyle As Style
> =A0 =A0 For Each myStyle In ActiveDocument.Styles
> =A0 =A0 =A0 =A0 If LCase(Right(myStyle.NameLocal, 5)) =3D "_diss" Then
> =A0 =A0 =A0 =A0 =A0 =A0 myStyle.Delete
> =A0 =A0 =A0 =A0 End If
> =A0 =A0 Next
> End Sub
>
> I prefer to use the LCase function to guard against possible differences i=
n the
> cases of the characters, for example, if the 'd' was upper case in some st=
yles
> but lower case in others.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP =A0 =A0 =A0 =A0FAQ: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