![]() |
#1
|
|||
|
|||
![]()
I have tried the macro recorder but all it comes up with is the following
Sub Macro6() ' ' Macro6 Macro ' ' Selection.Style = ActiveDocument.Styles("List 2") Selection.Style = ActiveDocument.Styles("List 3") End Sub I have a style named Style Body + Left: 0.89" (I did not create this and was auto generated) but I need to replace that style with a style named List 3. I can not find the style in Find and Replace either under the formatting styles either. I can see List 3 but not Style Body + Left: 0.89". Please Help |
#2
|
|||
|
|||
![]()
Styles with plus (+) show up in the Styles dropdown, but they are not "real" styles - they are not part of the searchable Styles collection. They are (sort of) temporary styles. Word puts them into the Styles dropdown (something I have always hated) when a manual format is made. A good reason to NEVER make manual formatting.
In other words, you can not use Find to find them. That being said, you could search for a Body style, and THEN test to see if there is a left indent of 0.89. |
#3
|
||||
|
||||
![]()
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
![]()
The code you provided worked like a charm. Thanks for the help.
|
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ravl13 | Word | 5 | 03-10-2013 05:04 PM |
![]() |
Jamal NUMAN | Word | 4 | 07-08-2011 04:12 AM |
![]() |
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 |