Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 04-01-2013, 06:31 PM
macropod's Avatar
macropod macropod is offline Macro to change style name with " in it Windows 7 64bit Macro to change style name with " in it Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,385
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

IIRC, the ' + Left: 0.89' doesn't denote part of the Style name, but a format that has been used to override it. Accordingly, you would have to Find paragraphs in the style named Style Body, then test their format to see whether they have the + Left: 0.89 formatting applied. The macro recorder won't do that. Try the following code:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Sty As Style, sOffset As Single
sOffset = CentimetersToPoints(0.89)
With ActiveDocument
  Set Sty = .Styles("Body Text")
  With .Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "^p"
      .Style = Sty.NameLocal
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindStop
      .Format = True
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Execute
    End With
    Do While .Find.Found
      With .Paragraphs(1)
        If CentimetersToPoints(Round(PointsToCentimeters(.LeftIndent), 2)) = _
          Sty.ParagraphFormat.LeftIndent + sOffset Then .Style = "List 3"
      End With
      .Collapse wdCollapseEnd
      .Find.Execute
    Loop
  End With
End With
Application.ScreenUpdating = True
End Sub
Note: the code assumes your 0.89 is Centimeters. If it's Inches, change 'Centimeters' in the code to 'Inches'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to change style name with " in it How to globally change the formatting of a bullet style to another style? ravl13 Word 5 03-10-2013 05:04 PM
Macro to change style name with " in it "Table of content" based on "Normal Style" behavior!!!! Jamal NUMAN Word 4 07-08-2011 04:12 AM
Macro to change style name with " in it How the "Style" and the "List" are linked?? Jamal NUMAN Word 1 06-30-2011 05:18 PM
"Change Word Options" don't change ADKREV Word 0 11-12-2010 10:56 AM
How do I change the "and" to "or" with multiple Rules (and Alerts)? bschimmel Outlook 0 11-16-2009 05:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:56 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