Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2017, 02:47 AM
macropod's Avatar
macropod macropod is offline Normalising styles with +condensed Windows 7 64bit Normalising styles with +condensed Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,518
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #2  
Old 02-12-2017, 03:41 AM
slaycock slaycock is offline Normalising styles with +condensed Windows 7 64bit Normalising styles with +condensed Office 2013
Expert
Normalising styles with +condensed
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

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
The troublesome styles disappear from view (but not from the document) in the style task pane if the show paragaph level formatting check box is unchecked (Style Pane Options dialog box - options from the style task pane)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Normalising styles with +condensed different hyperlink-styles in two superior styles -SLIME- Word 1 04-09-2016 08:51 AM
Normalising styles with +condensed Need some urgent condensed Project knowledge!! Halesowenmum Project 1 10-06-2014 06:18 PM
Normalising styles with +condensed 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
Normalising styles with +condensed Quick Styles Set saved but it doesnt appear at the styles list! Pedro77 Word 3 10-15-2011 05:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft