Copy specific text from one word file to another word file

Input Document.docx (258.2 KB) Output document.doc (232 KB)

Hi All,

I am struggling to get a solution for below scenario.
We need a solution to implement the below requirement in UiPath.

Input file- (attached for reference)

A word document having the below text in page number 2.

The text should be copied and pasted in output word file with certain formatting(font size and font name) as given below.

Don’t expect first COVID-19 vaccinations until early 2021: WHO’s Ryan

Malaysia’s Leading Index for May 2020 up 0.6%, first growth since February

RM4.8b for rural infrastructure development in Sabah

Thailand has not intervened in baht for trade advantage: central bank

Indonesia loan growth seen at 3%-4% in 2020: regulator

Singapore’s headline and core inflation remain in the red in June even as it exits circuit breaker

South Korea enters recession as exports plunge by most since 1963

U.S. weekly jobless claims rise; labor market recovery stalling

Republicans ditch coronavirus payroll tax cut, haggle over unemployment payments

UK trade deal unlikely for now: Britain, EU clash over post-Brexit ties

EU considers tax, emissions trading for carbon border plan

Italy approves new deficit hike to help coronavirus-hit economy

Output file - (sample Attached for reference – paste in highlighted Yellow area)

  • A word template having a table with 2 columns
  • The input text should be pasted in the 2nd column (the one that is highlighted)
  • The text should word wrap and should NOT overflow the column width
  • The bullets color should be RED

Adding to above, The text that is to be copied from Input file has hyperlinks embedded in it. So while pasting in Output file also, the text should come with hyperlinks embedded in it.

My findings: I had tried writing C# script using Invoke code. Through script I try to read Page 2 data of Input file but when I try pasting in output file through my script it throws error that selection cannot be pasted in table.

@garimavarshney9
Hi and welcome to the forum.

I don’t know what solutions you have already tried but what if you’re just using the clipboard to copy the text incl. the links to doc#2?

If i copy the text in clipboard, it becomes a string and the embedded hyperlinks go away.

Strange…I just tried it and it worked. How to you copy the text (what activity) to the clipboard?

Actually it works on the plain document files (like the one you have created).

But If I use the templates (input and output file that are attached to the post), it does not work. The input file’s data is not constant everytime but the format is (like the data to be copied is always on page 2). Because of this scenario I could not get any foreground activity that could be reliable for the requirement.

I tried writing c# script and invoked it through “Invoke code” activity. My script using Microsoft.office.interop.word to copy the page 2 range from input file.

Now using Uipath’s get clipboard text activity, I get the clipboard’s text in a string variable. Then I use “Set bookmark content” activitiy provided by uipath’s package " Uipath.word.activities" to paste the text in output file from the string variable (I added a bookmark to my output file manually )

Through this I am able to get the text in output file but the hyperlinks go away

…should work

Are copying the text from input file manually or through uipath activity?

Activity, of course. :wink:

ok, How did you manage to reach to Page 2 of input file through uipath activity so that we can do a click activity (the first step).

I know we can send Control G hotkey and then type “2” for this. But will that thing be reliable?
If I pick selector of the popup that comes after pressing control G, I am not sure if that will work on user’s machine as well once I deploy my Bot on user’s machine.

Also, After pasting this text to output file, How do I get proper formatting of this pasted text? Is it possible to achieve this through Invoke code or any uipath activity?
The desired formatting is like this (please see image )