![]() |
|
|
|
#1
|
|||
|
|||
|
I've created this macro to underline and bold specific text and number when found in my document.
Is there a way to combine and have the macro underline and bold in only one WITH statement? I may have complicated the macro, but it does work. Thanks! PHP Code:
|
|
#2
|
||||
|
||||
|
I'm surprised that it does work because I didn't know that there was a Word constant for wdBoldSingle - you should be using a boolean there.
You can simplify the code to Code:
Sub FormatMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "<Life Insurance>"
.Replacement.Text = ""
.MatchWildcards = True
.Format = True
.Replacement.Font.Underline = wdUnderlineSingle
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.Text = "<2.4.9>"
.Replacement.Font.Bold = True
.Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Microsoft Word macro to find text, select all text between brackets, and delete | helal1990 | Word VBA | 4 | 02-05-2015 03:52 PM |
Not Bold text but it comes up bold
|
Pluviophile | Word | 7 | 10-22-2013 10:29 AM |
| Format Bold in one line makes all lines bold | Nitte | Word | 2 | 02-07-2013 12:34 AM |
Set paragraph text to bold.
|
Sorcerer13 | Word | 1 | 09-04-2012 11:08 AM |
| How to remove the UNDERLINE from a hyperlink text? | Learner7 | PowerPoint | 3 | 05-17-2010 09:35 PM |