Hi everyone! I use Microsoft 365 for business. I am just learning about macros in Word, and I'm struggling with a problem I'm trying to solve. I have put together a list of 1,129 words and phrases that, if they appear in my weekly Word document, need to be in
Bold print. Some of the phrases have commas, and some may have apostrophes. There are definitely quite a few with dashes, and some slashes.
Note: I have the list in an Excel workbook right now.
I am trying to create a macro that will draw the list of terms from the excel workbook, search my document for each term and em
Bolden them as they are found.
So far, I've tried the following code. It is a slightly revised copy of an answer I found at stackoverflow for a similar question. They wanted highlighting, I believe, but otherwise it was very similar to my problem.
Sub Pre_List_for_Bold() ' Sub Pre_List_for_Bold()
Dim xl As Object 'Excel.Application
Dim wb As Object 'Excel.Workbook
Dim ws As Object 'Excel.Worksheet
Dim rng As Object 'Excel.Range
Dim cl As Object 'Excel.Range
Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Open("C:\biglist.xlsx") '## Modify as needed
Set ws = wb.Sheets(1) '##Modify as needed
Set rng = ws.Range("B3", ws.Range("B3").End(xlDown))
For Each cl In rng
Call EMBOLD_NEC_LIST(cl.Value, cl.Offset(0, 1).Value)
Next
End Sub
Sub EMBOLD_NEC_LIST(findText$, replaceText$)
'
' EMBOLD_NEC_LIST Macro
'
'
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = findText
.Replacement.Text = replaceText
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute
End Sub
'
End Sub
However, when I run the macro, I get the following error message:

Run-time error 1004: Application-defined or object-defined error
When I hit debug, it highlights the line I put in Red text above "Set rng = ws.Range("B3", ws.Range("B3").End(xlDown))"
I can't see what is wrong with the line, but then again I've only started learning this. If anyone has some ideas, I would be very grateful for the help.
Thank you!