Hi jsteff.
"I need to create a macro that will locate three different strings globally, like "Grand Total", "For Services Rendered" and "Due Date".
When the macro finds this text, I want it to make the text bold."
1. Please try and be more detailed and explicit. The fact is (apparently), you do NOT want to find the text and make the text bold. You want to find the text, and make everything
after the text (to the end of the paragraph I assume) bold. This is not the same as just finding specific text and making only it bold. According to what you originally asked about, it would be:
Total Due: $ 12,999.22
Although you did not mention Total Due - "I need to create a macro that will locate three different strings globally, like "Grand Total", "For Services Rendered" and "Due Date".
But you actually really want:
Total Due: $ 12,999.22
This is quite a different thing, although it should not be all that difficult.
2. As this is a VBA issue, again, further questions should be posted to the VBA forum.
IF your line (for example) Total Due: $ 12,999.22 is terminated by a paragraph mark, then it is fairly easy to do what you want.
Code:
Sub MakeItBold()
Dim r As Range
Dim var
Dim mySearch()
mySearch = Array("Due Date:", "Grand Total:", _
"For Services Rendered:", _
"Total Due:")
For var = 0 To UBound(mySearch)
Set r = ActiveDocument.Range
With r.Find
Do While .Execute(FindText:=mySearch(var), _
Forward:=True) = True
With r
.MoveEndUntil Cset:=vbCrLf
.Font.Bold = True
.Collapse 0
End With
Loop
End With
Next var
End Sub
What this does:
1. makes an array of your search phrases - mySearch
2. for each item of the array, it makes a Range object of the document
3. searches for the string
4. if found, makes the current range that found text extended to just before a paragraph mark
5. bolds the range
6. collapses the range to the end
7. looks for the next instance of the search string
8. repeats 3 - 7 for the next string in the array.
faq219-2884
Gerry
My paintings and sculpture