![]() |
#4
|
||||
|
||||
![]()
As indicated in my previous post, with that macro you can't delete linked Styles or Styles that are in use, so it seems that, apart from deleting as opposed to merely hiding Styles, it does what you want. To merely hide the unused Styles instead of deleting them, regarless of whether they're built-in or linked, you could use:
Code:
Sub HideUnusedStyles() Dim Doc As Document, bDel As Boolean Dim Rng As Range, StlNm As String, i As Long Application.ScreenUpdating = False On Error Resume Next Set Doc = ActiveDocument With Doc For i = .Styles.Count To 1 Step -1 With .Styles(i) bDel = True: StlNm = .NameLocal For Each Rng In Doc.StoryRanges With Rng With .Find .ClearFormatting .Format = True .Style = StlNm .Execute End With If .Find.Found = True Then bDel = False Exit For End If End With Next If bDel = True Then .Visibility = False End With Next End With Application.ScreenUpdating = True End Sub .Delete to: .Visibility = False
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
shmu | Misc | 4 | 02-18-2014 12:34 AM |
![]() |
OTPM | Project | 4 | 08-22-2013 01:33 PM |
Need Macro code for Outlook | gbaker | Outlook | 0 | 04-11-2013 10:29 AM |
![]() |
chefmate | Excel Programming | 1 | 08-26-2012 01:04 AM |
Macro to Table Style | ubns | Word VBA | 1 | 04-16-2012 05:01 AM |