#1
|
|||
|
|||
Separate text by numbers and change font
Hi All,
The first part of this I have fine with using the below. The part that isn't working is the changing of the font and color. I used the macro recorder, but apparently the syntax doesn't fit right. Code:
Sub CleanUpLines2() Application.ScreenUpdating = False With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting With .Replacement.Font .Bold = True .Color = -721371137 End With .Wrap = wdFindContinue .Format = False .MatchWildcards = True .Text = "([0-9]{1,2} )" .Replacement.Text = "^p\1" .Execute Replace:=wdReplaceAll End With Application.ScreenUpdating = True End Sub Code:
Sub Macro6() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find.Replacement.Font .Bold = True .Color = -721371137 End With With Selection.Find .Text = "([0-9]{1,2} )" .Replacement.Text = "^p\1" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll End Sub |
#2
|
||||
|
||||
Is there a reason your crafted code says ".Format = False" when the recorded code sets this to True?
Note that this would likely result in the paragraph mark being coloured & bold which would apply that to automatic paragraph numbers as a result - this might not be your intention.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Thanks Andrew. That was indeed the answer. I was using a boiler plate code and just didn't read all of the variable close enough.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
change font for all page numbers | lemonphenomenon | Word | 17 | 12-19-2020 03:20 PM |
How to change the font color of specific text within a Word table cell | epid011 | Word Tables | 2 | 05-15-2017 05:21 PM |
how to search and replace BOLD text >> font color change? | dylansmith | Word | 4 | 03-12-2013 09:51 PM |
Separate heading numbers | darksupernova | Word | 16 | 03-02-2013 06:09 AM |
How to change line height for marked text (in Word 2007)? ... as default for font? | pstein | Word | 1 | 01-14-2012 10:15 AM |