String parameter too long when replacing Text

I have a word template with some characters and keywords and when trying to replace a text, it failed because is more than 255 characters, any workaround on this issue? any update in the packages?

in order to test

  1. create a sequence

  2. add assign activity name: sample, value: “Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum”

  3. add word application scope and add a sample word document with a keyword of ##text## or any keyword

  4. Do a replace text Word activity like “##text##” : sample

run it and it will fail, then, cut the sample text to fit 250 chars and will work.

@Alex_Vasile

Why not split the string on something common like full stops, commas or new lines? Then you can replace the text for each item in the array and eventually piece it all back together?

Richard

that won’t work, at the end it replaces the ##text## with the required text and UiPath requires the full string to replace

can you try < stringvariable >.Replace(string1,##text##)

Use “LONG PATH TOOL” for issues like copying/ renaming and deleting long path files name.

Here is a sample workflow that replace a pattern in a Word document with a text larger than 255 characters. It does that by using multiple Test Replace with chunks of 255 or less characters.
WordReplaceLargeText.xaml (10.2 KB)

3 Likes

Hi Guyz how to use type into command correctly to type more than 500 character.as right now it misses strings in between

Hi @1vivek12,

Use set text activity.

Else in type into activity give “delaybetweenkeys”

Regards,
Arivu

hi thanks will try set text as delay between key was not working maybe as i am storing value in a variable from excel cell.

Hello Silviu. Could you please re-post this workflow? I am unable to see most of it due to an error message (Activity could not be loaded because of errors in the XAML).

I am also interested in using the Word replace activity with long strings.

Hi @Estuary,

Welcome to the community!

That workflow requires UiPath.Word.Activities package to be added to the project.
Here is how you can add it:

You can find out more about Managing Packages in our online documentation.

The dependencies are stored in the project configuration file (project.json) and restored when you open the project. But because I’ve only added the xaml file to the forum, when you opened the file in Studio it doesn’t know about dependencies and you have to added them manually.

Regards
Silviu

2 Likes

Thank you @Silviu, works perfectly, save me some time :slight_smile:

2 Likes

I have been using long path tool for this problem. It is convenient and easy to use and can delete, copy, move and bulk rename long path files or locked file easily.

Hey, I had almost the same issue as you and came up with a solution that you may like.

Split the text and save it into an array of strings, you can use “,” as a parameter and then edit it to eliminate the " " at the beginning of each item. The point is that you can have an array of texts, each item containing text less than 250 characters.

Then you can play with a counter and a guide inside a for each loop.
Let’s say that in your word file you have a key word that works as a pivot for replacing, let’s call it “(KEY)”.

In the for each loop, use an IF activity, and if the counter equals length of the array just use a normal replace, with “(KEY)” and item (the default value in the for each loop). BUT…if the condition is not met, you can replace “(KEY)” with item+" (KEY)". so that the loop of replacing continues until the last aarray element, on which the +" (KEY)" will not be added.

I hope I explained myself correctly.

It worked for me since i’m playing with a list of elements, in my case, work functions.

You gotta solve how to play with the pivot.