Removing styles

G

Guest

I understand that once a style has been used in a Word document (or template)
it will remain in the 'Styles in use' list even though no text is formatted
with this style. Is there anyway of removing such styles from the list to
prevent their normal use?
 
G

Guest

Hi Jeff-

You don't mention a version, and I can only comment on XP(2002) right now,
but I believe 2003 works the same. Also I assume you refer to the 'Show:'
list at the bottom of the Task Pane which actually refers to Formatting in
Use.

If I select what has a style applied to it and click 'Clear Formatting' on
the Task Pane, that style is removed from the list immediately. The same is
true if I apply a different style to the paragraph. (Both instances as long
as the style is not applied elsewhere in the doc.)

Once applied the style _will_ continue to appear in the Available Formatting
& the Available Styles list even if it is no longer used anywhere in the doc.

Is this not how it is for you? |:>)
 
S

Suzanne S. Barnhill

In the Format Style dialog (accessible using the Styles... button at the
bottom of the Format Settings dialog in Word 2002/2003), when you display
"Styles in use," you can delete (most) unused styles. User-defined styles
are actually deleted; Word's built-in styles (except for headings, Normal,
and Default Paragraph Font) are removed from the list and reset to their
Normal.dot default definition.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
K

Klaus Linke

Geoff O said:
I understand that once a style has been used in a Word document (or template)
it will remain in the 'Styles in use' list even though no text is formatted
with this style. Is there anyway of removing such styles from the list to
prevent their normal use?


Hi Geoff,

You can also use a macro to delete unused styles.
It's probably the macro I use most often (see below).
It'll show you where some style occurs, too (so you can quit the macro with Ctrl+Pause at that time and fix the document if the style was used erroneously).

Regards,
Klaus


Sub DeleteUnusedStyles()
Dim myStyle As Style
For Each myStyle In ActiveDocument.Styles
If myStyle.InUse Then
Select Case myStyle
Case ActiveDocument.Styles(wdStyleDefaultParagraphFont)
Case ActiveDocument.Styles(wdStyleNormal)
Case ActiveDocument.Styles(wdStyleNormalTable)
Case ActiveDocument.Styles(wdStyleHeading1) To _
ActiveDocument.Styles(wdStyleHeading9)
Case Else
Selection.Collapse (wdCollapseStart)
With Selection.Find
.ClearFormatting
.Style = myStyle
.Forward = True
.Wrap = wdFindContinue
.Execute FindText:="", Format:=True
If .Found = False Then
StatusBar = myStyle.NameLocal
If MsgBox("Delete?", vbYesNo, myStyle.NameLocal) = vbYes Then
myStyle.Delete
End If
Else
If MsgBox("Keep?", vbYesNo, myStyle.NameLocal) = vbNo Then
myStyle.Delete
End If
' End
End If
End With
End Select
End If
Next myStyle
End Sub
 
G

Guest

Regards,
Klaus


Sub DeleteUnusedStyles()
Dim myStyle As Style
For Each myStyle In ActiveDocument.Styles
If myStyle.InUse Then
Select Case myStyle
Case ActiveDocument.Styles(wdStyleDefaultParagraphFont)
Case ActiveDocument.Styles(wdStyleNormal)
Case ActiveDocument.Styles(wdStyleNormalTable)
Case ActiveDocument.Styles(wdStyleHeading1) To _
ActiveDocument.Styles(wdStyleHeading9)
Case Else
Selection.Collapse (wdCollapseStart)
With Selection.Find
.ClearFormatting
.Style = myStyle
.Forward = True
.Wrap = wdFindContinue
.Execute FindText:="", Format:=True
If .Found = False Then
StatusBar = myStyle.NameLocal
If MsgBox("Delete?", vbYesNo, myStyle.NameLocal) = vbYes Then
myStyle.Delete
End If
Else
If MsgBox("Keep?", vbYesNo, myStyle.NameLocal) = vbNo Then
myStyle.Delete
End If
' End
End If
End With
End Select
End If
Next myStyle
End Sub

Hi Klaus:

Thank you for this, but mine crashed... it never addressed the style I was
trying to get rid of (I have a reoccurring problem with certain styles
popping up (usually a font/indent oddity created by someone else) and I'm
unable to erase them). It crashed at teh 'no list' style and gave me a
run-time '4198' error. When I click debug, it highlights the myStyle.Delete
line of code.

I usually select all instances of the offending Word-created style and just
hit delete, but once in a while, there are these buggy ones that linger and
they drive me crazy. I try to select them, and nothing selects. I try to
delete the style and nothing happens.

I'm wondering if anyone knows another way?

My offenders are: 10 pt, Before: 0 pt; 10 pt, Bold, left: .83" space before
0 pt and their bold brethren.

I've scoured these groups to try to solve this, and it is driving me batty.
Any help would be great!
 
G

Guest

I love the tool, guys, but the darn 10pt style is still in there. I can't
delete it. What does it take?
 
K

Klaus Linke

I run into similar problems. Typical offenders are styles that Word created
automatically and that start with a space character.

Sorry, I don't know any way to get rid of them with VBA.

Two options:

Make sure the problematic styles aren't applied any more, then paste without
the final paragraph mark into a new doc.
The problematic styles should be left behind... but you may have to fix
stuff (headers/footers...).

The other option is to save in XML format, open as a text file, and fix or
delete the problematic style definitions.

Regards,
Klaus
 
G

Guest

Klaus Linke said:
I run into similar problems. Typical offenders are styles that Word created
automatically and that start with a space character.

Yes, Word created this automatically.

Two options:

Make sure the problematic styles aren't applied any more, then paste without
the final paragraph mark into a new doc.

I did this (probably right before you posted this). Thank you. Maybe this
will help someone else in the future! The key is not including that
paragraph mark, though, definitely.
The problematic styles should be left behind... but you may have to fix
stuff (headers/footers...).

The other option is to save in XML format, open as a text file, and fix or
delete the problematic style definitions.

I may do that in the future. Thank you.
 

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