View Single Post
 
Old 03-16-2015, 09:39 AM
ksigcajun ksigcajun is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default Select text to be underline and bold

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:
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
         End With
        Set oRng 
ActiveDocument.Range
  With oRng
.Find
    
.ClearFormatting
    
.Replacement.ClearFormatting
    
.Text "<2.4.9>"
    
.Replacement.Text "^&"
    
.MatchWildcards True
    
.Format True
    
.Replacement.Font.Bold wdBoldSingle
    
.Execute Replace:=wdReplaceAll
  End With
  End Sub 
Reply With Quote