A
andreas
Dear Experts:
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 = ActiveDocument
Set styl = doc.Styles.Add(Name:="Style1")
On Error Resume Next
doc.Styles("Heading 2 Char").LinkStyle = styl
styl.Delete End Sub
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 = ActiveDocument
Set styl = doc.Styles.Add(Name:="Style1")
On Error Resume Next
doc.Styles("Heading 2 Char").LinkStyle = styl
styl.Delete End Sub