![]() |
|
#8
|
||||
|
||||
|
Try:
Code:
Sub DeleteUnusedStyles()
Dim Doc As Document, Rng As Range, Shp As Shape
Dim StlNm As String, i As Long, bDel As Boolean
Application.ScreenUpdating = False
On Error Resume Next
Set Doc = ActiveDocument
With Doc
For i = .Styles.Count To 1 Step -1
With .Styles(i)
If .BuiltIn = False And .Linked = False Then
bDel = True: StlNm = .NameLocal
For Each Rng In Doc.StoryRanges
With Rng.Find
.ClearFormatting
.Format = True
.Style = StlNm
.Execute
If .Found = True Then
bDel = False
Exit For
End If
End With
For Each Shp In Rng.ShapeRange
If Not Shp.TextFrame Is Nothing Then
With Shp.TextFrame.TextRange.Find
.ClearFormatting
.Format = True
.Style = StlNm
.Execute
If .Found = True Then
bDel = False
Exit For
End If
End With
End If
Next
Next
If bDel = True Then .Delete
End If
End With
Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Tags |
| delete unused, macro, styles |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to delete unused cell remaining at end of a block of deleted data | SKEETER | Excel | 2 | 10-24-2017 07:06 AM |
Macro to Import Styles
|
John9210 | Word VBA | 1 | 02-06-2015 04:47 PM |
| Remove unused bottom white space. | johnatanasoff | Word | 4 | 11-05-2014 06:07 PM |
| transfering outlook PST to a new pc, unused storage folder and suggested contacts | burgers | Outlook | 1 | 06-14-2011 04:05 PM |
| Unused to Outlook need to save folders - help? | franontheedge | Outlook | 0 | 10-31-2007 07:47 AM |