thinksalot
03-04-2006, 06:33 PM
I wrote this macro to find terms and only replace the first occurrence with term and either a registration mark or a trademark. It works beautifully. However, I am still faced with three issues.
I would like to skip terms that are italicized (done) or in Courier font.
I would like to include Arial in my search as well, as I will replace the first instance of the word whether it's in Times New Roman or Arial font.
I would also like to include footnotes in my search. I have seen a few posts on the subject, but none seem to work for me.
If you have any ideas or solutions, feel free to share. Thank you.
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Windows"
.Replacement.Text = "Windows?"
.Font.Italic = False
.Font.Name = "Times New Roman"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = True
End With
Selection.Find.Execute
Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, Count:=3, Name:=""
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
End If
.Find.Execute
End With
I need to duplicate this code for each term, so have replaced text with words Bluetooth(R), Proctor & Gamble(R), stuff like that, and am merely using a list of terms in the various fonts (Ariel, Courier and Times New Roman) to conduct the search as it works the same. I have a real document but cannot share here.
Windows
Bluetooth
Proctor & Gamble
Windows
Bluetooth
Proctor & Gamble
Windows
Bluetooth
Proctor & Gamble
This find and replace starts in the third section of my document, as I want to avoid the cover page and Table of Contents.
I would like to skip terms that are italicized (done) or in Courier font.
I would like to include Arial in my search as well, as I will replace the first instance of the word whether it's in Times New Roman or Arial font.
I would also like to include footnotes in my search. I have seen a few posts on the subject, but none seem to work for me.
If you have any ideas or solutions, feel free to share. Thank you.
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Windows"
.Replacement.Text = "Windows?"
.Font.Italic = False
.Font.Name = "Times New Roman"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = True
End With
Selection.Find.Execute
Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, Count:=3, Name:=""
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
End If
.Find.Execute
End With
I need to duplicate this code for each term, so have replaced text with words Bluetooth(R), Proctor & Gamble(R), stuff like that, and am merely using a list of terms in the various fonts (Ariel, Courier and Times New Roman) to conduct the search as it works the same. I have a real document but cannot share here.
Windows
Bluetooth
Proctor & Gamble
Windows
Bluetooth
Proctor & Gamble
Windows
Bluetooth
Proctor & Gamble
This find and replace starts in the third section of my document, as I want to avoid the cover page and Table of Contents.