I cobbled together the below. I am trying to iterate through an excel columns. I want to find the string in column A in a Word document and insert a hyperlink based on a string in column B. This keeps giving me a 438 Error "object doesn't support this property or method" error. Any help or suggestions are greatly appreciated
Sub Replace()
Dim pathh As String
Dim pathhi As String
Dim oCell As Integer
Dim from_text As String, to_text As String
Dim WA As Object
Dim myRange As Object
pathh = "C:\Users\sferr\Desktop\Replace Test\Test.docx"
Set WA = CreateObject("Word.Application")
WA.Documents.Open (pathh)
WA.Visible = True
For oCell = 1 To 100
from_text = Sheets("Sheet1").Range("A" & oCell).Value
to_text = Sheets("Sheet1").Range("B" & oCell).Value
Next oCell
With WA.ActiveDocument
Do While .Execute(FindText:=from_text, MatchWholeWord:=True, Forward:=True) = True
Set myRange = .Content
With myRange.Find
.Execute FindText:=from_text
.Hyperlinks.Add Anchor:=myRange, Address:=to_text
End With
myRange.Collapse Direction:=wdCollapseEnd
Loop
End With
End Sub