cancel
Showing results for 
Search instead for 
Did you mean: 

MS Outlook VBO - Replace String

Jessie_Jaye_IIQ
Level 3
​Hello All,

Not sure what is the best way to do it but I recently tried  to write a code stage to replace a special character in a given range. It was working fine and as a form of control I added a condition in the code stage to check if the special character(s) are available in the range before it even executes the replace command line. However the condition does not seem to be working. Can anyone advice?


RepString, StringToRep are data items
range = "A:A"

Dim worksheet, excel, range As Object
worksheet = GetWorkbook(handle,Nothing).ActiveSheet
Try

excel = worksheet.Application

range = excel.Selection

if excel.match(StringToRep,range) > 0 then <---------------------------- the condition I mentioned above
 range.Replace(StringToRep, RepString) <------------------- works fine
end if

Finally
 worksheet = Nothing
 excel = Nothing
 range = Nothing
End Try

Does anyone have a suggestion?

------------------------------
Jessie Jaye II Quema
RPA Configurator
HSBC
Asia/Hong_Kong
------------------------------
0 REPLIES 0