Replace Text only replacing first occurrence

Hello UiPath Community!

I have a word document and trying to replace values/words from 2 excel spreadsheets. One excel spreadsheet has the original values in the word doc. The second excel contains the values I am trying to change the word doc values/words to.

I use the Replace Text activity. When both of the boxes are variables, the bot only changes the first occurrence of the value/word. I cannot use a version more recent than 1.3.0 Word Activities Package because of restrictions. I Write Line shows the correct output.

Sequence is:
Excel Application Scope- Read Cell output prevObligation
Excel Application Scope- Read Cell output currentObligation
Word Application Scope- Replace Text - prevObligation = current Obligation
Only the first occurrence changed.

Thank you for your help!!

@Jessica_Moseley - Is the there a way, you can Click “Replace All” for every search.

I am running into the same issue when I click “Replace All.” It found the first occurrence and changed it but there are 4 occurrences it didn’t change.

I changed my variable values to string and although Replace Text activity does not work, so far it looks like Replace All in Word supports my efforts.

Thank you!

I spoke too soon. The Replace All activity in Word worked once after I changed the variable type to String from Generic. Now it is only correcting the first occurrence again.

Please help.

@Jessica_Moseley - once I am back I will try something and share the sample.

Thank you!

@Jessica_Moseley - Here is the sample workflow i have tried…where i can took text from excel and used it for replace all occurence in word.

Before
image

After
image

XAML : ReplaceAll_Word.zip (31.2 KB)

Please try and let me know. if it works, please mark this as solution.

I am reading a budget so data I need is dispersed throughout the spreadsheet and in 2 separate sheets, not in columns/rows ex. E52 output is prevObligation variable, C19 output is currentObligation variable.

@Jessica_Moseley - Use those Cell Numbers(After storing that cell value in a variable) in the type into variable.

Idea for Replace all is : Ctrl H --> Type Into “Find” --> Type Into “Replace” --> Alt A --> Enter --> Alt F4.

I did use those cell number output variable in the type into.

I will try the Ctrl H option and let you know how it goes.

@Jessica_Moseley - Ctrl H --> Will bring the Replace Pop up on to the screen. For Replace All, I used “Alt + A”…Please see the below screenshot, in the “Replace All” word Ais underlined, so I sent Alt +A key…That’s it…

image

Thank you for your help and support!

After watching it run closely, I discovered the first variable had a white space after it. Once I put variable.replace(" ", “”) in the Type Into activity- Find What field, Word replaced all of the occurrences.

@Jessica_Moseley - Glad it helped in few parts. you can mark it as solution, if any of my suggestion helped, so that this thread will be closed. :slight_smile:

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