![]() |
|
|
|
#1
|
||||
|
||||
|
Try:
Code:
Sub DeleteCondensedStyles()
Dim Doc As Document, i As Long, Rng As Range, StlNmFnd As String, StlNmRep As String
Application.ScreenUpdating = False
Set Doc = ActiveDocument
With Doc
For i = .Styles.Count To 1 Step -1
With .Styles(i)
If .BuiltIn = False Then
If .Type = wdStyleTypeCharacter Then
StlNmFnd = .NameLocal
If InStr(StlNmFnd, "+") > 0 Then
StlNmRep = Trim(Split(StlNmFnd, "+")(0))
For Each Rng In Doc.StoryRanges
With Rng.Find
.ClearFormatting
.Format = True
.Style = StlNmFnd
.Replacement.Style = StlNmRep
.Execute Replace:=wdReplaceAll
End With
Next
If .Linked = True Then
Doc.Styles.Add Name:="TmpSty"
.LinkStyle = "TmpSty"
Doc.Styles("TmpSty").Delete
Else
.Delete
End If
End If
End If
End If
End With
Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Macropod
Thanks for the suggestion. Unfortunately when iterating through the style collection the troublesome styles are not found. i.e. the following code prints nothing. Code:
Sub findplus()
Dim myindex As Long
For myindex = 1 To ActiveDocument.Styles.Count
If InStr(ActiveDocument.Styles(myindex).NameLocal, "+") > 0 Then
Debug.Print ActiveDocument.Styles(myindex).NameLocal
End If
Next
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
different hyperlink-styles in two superior styles
|
-SLIME- | Word | 1 | 04-09-2016 08:51 AM |
Need some urgent condensed Project knowledge!!
|
Halesowenmum | Project | 1 | 10-06-2014 06:18 PM |
Restricting paragraph styles without restricting character styles
|
Red Pill | Word | 5 | 05-25-2012 01:06 PM |
| Can't Display "Recently Used Styles" in Styles Pane | mwildem | Word | 2 | 05-23-2012 01:42 PM |
Quick Styles Set saved but it doesnt appear at the styles list!
|
Pedro77 | Word | 3 | 10-15-2011 05:17 AM |