Thread: Remove Styles
View Single Post
  #7   Report Post  
Posted to microsoft.public.word.formatting.longdocs
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Remove Styles

Hi Jim,

You could try something based on:

Sub Demo()
Dim Sty As Style
For Each Sty In ActiveDocument.Styles
If Sty.BuiltIn = False Then Sty.Delete
Next
End Sub

Unfortunately, you lose all of the formatting associated with the deleted Styles in the text that used them.

What you can do, however, is to delete all the Styles that aren't being used, leaving only the used ones to process. For this you
could try something based on:

Sub Demo()
Dim Sty As Style
With ActiveDocument
For Each Sty In .Styles
If Sty.BuiltIn = False Then
With .Content.Find
.ClearFormatting
.Text = ""
.Style = Sty.NameLocal
.Execute Format:=True
If .Found = False Then
Sty.Delete
Else
MsgBox "Style: " & Sty.NameLocal & " is in use."
End If
End With
End If
Next
End With
End Sub

From there it's be a matter of using Find to locate each use of the reported 'in use' Styles, capturing the relevant attributes,
changing the range's Style to a suitable built-in Style and then either modifying that Style to suit or hard-formatting the range
with the formerly-applied Style's attributes. Once that's done for all ranges in that Style, the Style can safely be deleted.

--
Cheers
macropod
[Microsoft MVP - Word]


wrote in message ...
Thanks . Actually I was referring to styles I added nit the default
built in styles

In terms of the power of styles although I agree it would be nice I do
find that using styles with multi-level lists (which is what I did) to
be somewhat cumbersome. It would be a hard sell

Thanks for your help

FYI I tried the VBA command
ActiveDocument.Styles("Custom1").Delete

but that genereate a vba error



On Thu, 7 Jan 2010 21:21:59 +1100, "macropod"
wrote:

Hi Jim,

If you're referring to the built-in Styles, you can't remove them. A far better approach is to demonstrate the power of Styles to
the company and, when the light bulb brightens, teach the workers how to use them.