T
Tina
I created several macros to make an acronym list. Part of
the code is:
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = False
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "COMSEC"
.Replacement.Text = "Communications Security
(COMSEC)"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.Format = True
.MatchCase = True
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.HomeKey Unit:=wdStory
The macro runs wonderfully. I update the database with
new acronyms, run a mail merge, and paste it into vba.
All I need to know is how to find the exact phrase
(string?). If I want to find and replace "Communications
Security" with "COMSEC", I don't want it to change an
instance of "Telecommunications Security". I want it to
find the whole exact phrase.
Forgive me. I'm new at writing code.
the code is:
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = False
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "COMSEC"
.Replacement.Text = "Communications Security
(COMSEC)"
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.Format = True
.MatchCase = True
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseStart
Else
.Collapse Direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse Direction:=wdCollapseEnd
Else
.Collapse Direction:=wdCollapseStart
End If
.Find.Execute
End With
Selection.HomeKey Unit:=wdStory
The macro runs wonderfully. I update the database with
new acronyms, run a mail merge, and paste it into vba.
All I need to know is how to find the exact phrase
(string?). If I want to find and replace "Communications
Security" with "COMSEC", I don't want it to change an
instance of "Telecommunications Security". I want it to
find the whole exact phrase.
Forgive me. I'm new at writing code.