Anyone help me with the below show me where im going wrong???
Error listed below
--------------------------------
Sub all()
Dim wdapp As Object
On Error Resume Next
Set wdapp = GetObject(, "Word.Application")
On Error GoTo 0
If wdapp Is Nothing Then
MsgBox "No instances of Word found"
Exit Sub
End If
Dim Wbk As Workbook: Set Wbk = ThisWorkbook
Dim Dict As Object
Dim RefList As Range, RefElem As Range
Set Dict = CreateObject("Scripting.Dictionary")
Set RefList = Wbk.Sheets("Sheet1").Range("C2:C16")
With Dict
For Each RefElem In RefList
If Not .Exists(RefElem) And Not IsEmpty(RefElem) Then
.Add RefElem.Value, RefElem.Offset(0, 1).Value
End If
Next RefElem
End With
For Each Key In Dict
With wdapp.Application.Find 'run time error 438
If Dict(Key) = "" Then
.Execute FindText:=Key & "^p", ReplaceWith:=Dict(Key)
Else
.Execute FindText:=Key, ReplaceWith:=Dict(Key)
End If
End With
Next Key
End Sub
Error listed below
--------------------------------
Sub all()
Dim wdapp As Object
On Error Resume Next
Set wdapp = GetObject(, "Word.Application")
On Error GoTo 0
If wdapp Is Nothing Then
MsgBox "No instances of Word found"
Exit Sub
End If
Dim Wbk As Workbook: Set Wbk = ThisWorkbook
Dim Dict As Object
Dim RefList As Range, RefElem As Range
Set Dict = CreateObject("Scripting.Dictionary")
Set RefList = Wbk.Sheets("Sheet1").Range("C2:C16")
With Dict
For Each RefElem In RefList
If Not .Exists(RefElem) And Not IsEmpty(RefElem) Then
.Add RefElem.Value, RefElem.Offset(0, 1).Value
End If
Next RefElem
End With
For Each Key In Dict
With wdapp.Application.Find 'run time error 438
If Dict(Key) = "" Then
.Execute FindText:=Key & "^p", ReplaceWith:=Dict(Key)
Else
.Execute FindText:=Key, ReplaceWith:=Dict(Key)
End If
End With
Next Key
End Sub