#1
|
|||
|
|||
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. |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
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: |
#4
|
|||
|
|||
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 |
#5
|
|||
|
|||
I'm sorry for the confusion in my reply but what you have written works perfectly. I appreciate the help.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find, select, and replace part of text with bold | paik1002 | Word VBA | 4 | 12-07-2015 11:24 PM |
Adding bold colons at end of bold row headings | bertietheblue | Word Tables | 2 | 07-26-2015 07:26 AM |
Select text to be underline and bold | ksigcajun | Word VBA | 1 | 03-16-2015 07:51 PM |
Find/Replace Wildcard Needed-Bold & Highlight | rsrasc | Word VBA | 3 | 11-11-2014 03:55 PM |
find and replace in bold | redzan | Word VBA | 1 | 07-27-2014 03:35 PM |