Replace Text in Document: Index and length must refer to a location within the string. (Parameter 'length')

HI,
I am in a Automation where i am editing word form(image given below) using replace text in document activity. but problem is that i want to run activitys till index have some value.
e.g str_name=“PRAKASH” its replaceing text till GGGG correctly but its giving error on HHHH because no index on 7.
how can i skip from HHHH activity so i will not get any error? I need empty box if no index left.please let me know if you have any other approach.


Hi @Hemant_Deshmukh,

This usually occurs attempting to manipulate a string with a starting index or length that exceeds the bounds of the string.
So, I suggest to have a writeline/ Messagebox to see if your substring is giving correct results

Hope this may help you

Thanks,
Srini

Wrap your logic to replace with sub-string in Try Catch,
whenever you get error due ‘index out of bound exception’, handle it in Catch block

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.