Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-16-2015, 09:39 AM
ksigcajun ksigcajun is offline Select text to be underline and bold Windows 7 64bit Select text to be underline and bold Office 2010 64bit
Advanced Beginner
Select text to be underline and bold
 
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
 



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
Select text to be underline and bold 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
Select text to be underline and bold 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:07 AM.


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