Thread: [Solved] Find & Replace Unique word
View Single Post
 
Old 05-24-2017, 01:21 AM
raghugada raghugada is offline Windows XP Office 2007
Novice
 
Join Date: Apr 2017
Posts: 21
raghugada is on a distinguished road
Default Run-time error '5560'

I have added the code below which still showing me the same error



In the excel sheet there are 725 rows try for all the of the rows
try to test fully on your end fully then
Try to execute fully on your end

If you can't solve the problem then tell me clearly don't blame me or rotate
try to understand the problem.

Simply assuming the problem and giving me a solution.
First try to test on your end and then tell me
If you are honestly testing you will get error

Be prompt in your work donot simply guess and reply

Sub RemoveShreeLipiDistortionUsingWildCards1()
Application.ScreenUpdating = False
Dim objExcel As Object, Counter As Long, i As Long, j As Long
Dim StrFnd, StrRep As String
Const StrEsc As String = "(){}[]<>-@\!?*"
Dim iDataRow As Long
Set objExcel = CreateObject("Excel.Application")
Set exWb = objExcel.Workbooks.Open(ActiveDocument.path + "\List of ShreeLipi Distortion (1).xlsx")
With exWb.Worksheets(1)
Counter = .Cells(.Rows.Count, 1).End(-4162).Row
'Counter = .Range("A" & .Cells.SpecialCells(11).Row).End(-4162).Row ' 11 = xlCellTypeLastCell, -4162 = xlUp
'MsgBox Counter
'MsgBox iDataRow
'End
For i = 2 To Counter
StrFnd = Replace(.Range("A" & i), "^", "^^")
StrRep = Replace(.Range("B" & i), "^", "^^")
For j = 1 To Len(StrEsc)
StrFnd = Replace(StrFnd, Mid(StrEsc, j, 1), "\" & Mid(StrEsc, j, 1))
StrRep = Replace(StrRep, Mid(StrEsc, j, 1), "\" & Mid(StrEsc, j, 1))
Next
'MsgBox StrRep
StrFnd = Replace(StrFnd, "^", "^094")
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Format = False
.MatchWildcards = True
.Wrap = wdFindContinue
.Text = "<" & StrFnd & ">"
.Replacement.Text = StrRep
.Execute Replace:=wdReplaceAll
End With
Next i
'exWb.Close False
End With
Set exWb = Nothing: Set objExcel = Nothing
Application.ScreenUpdating = True
End Sub
Attached Images
File Type: jpg Run-time error '5560'.JPG (12.2 KB, 16 views)