Group: microsoft.public.word.vba.general
From: andreas
Date: Saturday, March 22, 2008 5:05 AM
Subject: Re: Cleaning out all linked "Char"-Styles in one go

On Mar 22, 5:35=A0am, "Klaus Linke" wrote:
> Hi Andreas,
>
> Which version do you use? Word 2007 has a new property for styles, .Linked=
,
> which can make it easier.
>
> In previous versions, I tested each character(!) style on whether it was
> linked to a paragraph style.
> Then if that wasn't the "Normal" (Standard) style, I checked the linked
> paragraph style whether it was linked to the character style.
> Any regular character style will report "Normal" as its linked style (...
> pretty weird, but it's not my design).
>
> It seems to me, if those two conditions are met, it's a Char style.
> The name doesn't matter much... In German, it's "Zchn" rather than "Char",=

> in other countries other names.
> "Char Char" styles are actually paragraph styles created by one of the
> several bugs involved.
> Also, any built-in or user-defined style (without "Char" in its name) can
> become a linked style of some paragraph style (sometimes it seems
> spontaneously by bugs).
>
> So after that test, I'd link the Char style to the Normal paragraph style.=

> That turns it into a "plain" character style that you can see in the
> interface (which you usually can't before, in Word 2003).
>
> If you simply delete it (or link it to some new paragraph style and delete=

> that paragraph style, as your macro does), you'll loose all the formatting=

> that was done by the character style, and it'll revert to the default
> paragraph font.
>
> Maybe that's no problem for you, but in the documents I get, it often does=
.
> So once the character styles are visible in the styles pane, I'll have to =
go
> through them and decide whether to turn them into something else, or remov=
e
> them (and their formatting).
>
> Regards,
> Klaus
>
>
>
> "andreas" wrote:
> > Dear Experts:
>
> > =A0 Below code which I found on the Internet creates a new style
> > ("Style1"), links the "Char" style that bases on "Heading 2" to this
> > new style, then deletes the new style.1.
> > This way one can easily get rid of these awful linked character
> > styles. These rogue characther styles (e.g. Heading 1 Char Char) are
> > automatically created if one tries to apply a paragraph style to just
> > part of a paragraph.
>
> > The trouble is, I got a document which has literally hundreds of these
> > (rogue) linked Character Styles. Is there a way to alter below code to
> > include all linked "Char" Styles regardless of their exact name (e.g.
> > Heading 1 Char Char Char or Table Body Text Char Char Char Char or
> > just Char Char).
>
> > Help is much appreciated.
> > Thank you very much in advance.
>
> > Regards, Andreas
>
> > Sub DeleteHeading2Char()
> > Dim styl As Word.Style, doc As Word.Document
> > Set doc =3D ActiveDocument
>
> > Set styl =3D doc.Styles.Add(Name:=3D"Style1")
> > On Error Resume Next
> > doc.Styles("Heading 2 Char").LinkStyle =3D styl
> > styl.Delete
End Sub- Hide quoted text -
>
> - Show quoted text -

Dear Klaus,

thank you for your your very detailed description of the problem with
these rogue "Char" Styles. I was not aware of all of what you said,
hence it is very helpful to me.
Ok, the following code links a specific "Char" style to the normal
style.

ActiveDocument.Styles("BodyText Char Char").LinkStyle =3D
ActiveDocument.Styles(wdStyleNormal).

My initial problem remains. Is it possible to link all "Char"-Styles
to the Normal style in one go? I try to avoid to enter dozens and
dozens of these Char-Styles one after the other in between the
parentheses of above code.

Help is much appreciated. Thank you in advance. Regards, Andreas



Safety Articles | Usenet Groups | Usenet News | Bluegrass