Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2016, 04:11 PM
redzan redzan is offline Macro to find and replace headings in bold and underline Windows 7 32bit Macro to find and replace headings in bold and underline Office 2003
Advanced Beginner
Macro to find and replace headings in bold and underline
 
Join Date: Feb 2012
Posts: 37
redzan is on a distinguished road
Default Macro to find and replace headings in bold and underline


Hello,

I know how to record macros. I need help writing one. I want word to find and replace several headings in bold and underline. Can someone help me with this?

Thank you!

P.S. I use word 2003 and do know how to copy a new macro into VBA.
Reply With Quote
  #2  
Old 02-12-2016, 08:05 PM
macropod's Avatar
macropod macropod is offline Macro to find and replace headings in bold and underline Windows 7 64bit Macro to find and replace headings in bold and underline Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Do these headings use a particular Style? If not, how is Word supposed to differentiate ordinary text in bold and underline from headings in bold and underline? Once found, what is the macro supposed to do with the content?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-13-2016, 08:53 AM
redzan redzan is offline Macro to find and replace headings in bold and underline Windows 7 32bit Macro to find and replace headings in bold and underline Office 2003
Advanced Beginner
Macro to find and replace headings in bold and underline
 
Join Date: Feb 2012
Posts: 37
redzan is on a distinguished road
Default

Right now I have to find and replace each one making them bold and underline. I'm just trying to do it all at once instead of one at a time. I have a list of the headings below.

HISTORY OF PRESENT ILLNESS:
PHYSICAL EXAM:
RADIOGRAPHS:
SOCIAL HISTORY:
FAMILY HISTORY:
REVIEW OF SYSTEM:
BRIEF HISTORY:
CLINICAL EXAM:
ASSESSMENT AND PLAN:
IMPRESSION AND PLAN:
Reply With Quote
  #4  
Old 02-13-2016, 09:10 AM
gmaxey gmaxey is offline Macro to find and replace headings in bold and underline Windows 7 32bit Macro to find and replace headings in bold and underline Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You didn't answer the question asked. If a particular style is applied to all of the headings (and not other text) then it is simply a matter of modifying the style to include bold and underline font attributes.

Regardless, here is a macro that might meet your needs:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim arrFind() As String
Dim lngIndex As Long
Dim oRng As Range
  arrFind = Split("HISTORY OF PRESENT ILLNESS:,PHYSICAL EXAM:,RADIOGRAPHS:,SOCIAL HISTORY:,FAMILY HISTORY:,REVIEW OF SYSTEM:," _
                & "BRIEF HISTORY:,CLINICAL EXAM:,ASSESSMENT AND PLAN:,IMPRESSION AND PLAN:", ",")
  For lngIndex = 0 To UBound(arrFind)
    Set oRng = ActiveDocument.Range
    With oRng.Find
      .Text = arrFind(lngIndex)
      With .Replacement
        .Text = arrFind(lngIndex)
        .Font.Bold = True
        .Font.Underline = True
      End With
      .Execute Replace:=wdReplaceAll
    End With
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 02-13-2016, 12:24 PM
redzan redzan is offline Macro to find and replace headings in bold and underline Windows 7 32bit Macro to find and replace headings in bold and underline Office 2003
Advanced Beginner
Macro to find and replace headings in bold and underline
 
Join Date: Feb 2012
Posts: 37
redzan is on a distinguished road
Default

I'm sorry for the confusion in my reply but what you have written works perfectly. I appreciate the help.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find and replace headings in bold and underline Find, select, and replace part of text with bold paik1002 Word VBA 4 12-07-2015 11:24 PM
Macro to find and replace headings in bold and underline Adding bold colons at end of bold row headings bertietheblue Word Tables 2 07-26-2015 07:26 AM
Macro to find and replace headings in bold and underline Select text to be underline and bold ksigcajun Word VBA 1 03-16-2015 07:51 PM
Macro to find and replace headings in bold and underline Find/Replace Wildcard Needed-Bold & Highlight rsrasc Word VBA 3 11-11-2014 03:55 PM
Macro to find and replace headings in bold and underline find and replace in bold redzan Word VBA 1 07-27-2014 03:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft