Copying text sections from master Word document and creating three new Word documents

Hello everyone - I am new to UIPath Studio, but am currently over half way complete with the Foundation Academy training. I am also tasked with an initial project to take in a master Word document and breaking it apart into three separate sections each of which will be its own Word document. These new documents also need to maintain the formatting of the original word document.

I have tried recording, screen scraping, data scraping and UI Explorer, but I am so new to this tool that I have not found any to be successful. I also search through the community forum, but have not found anything trying to do this specific task. I have added the UiPath.V7.Activities and UiPath.Word.Activities to be able to select the folder and open the document.(using Word Application Scope)

I need to know the best technique to:

  1. Select a block of text based on a paragraph heading (Paragraph 1, 2 and 3) in the master word document. (has to be with selectors, but I only seem to be able to select the whole master doc?)
  2. Create three new word documents inserting for each block of text above (Paragraph 1, 2 and 3).

I am attaching a sample word doc and my main.xaml so far. (27.6 KB)

Thanks in advance.

Your best bet for separating this content into 3 separate files would be to use the read text activity for Word, and then use string manipulation to separate this data into the other 3 Word documents. This can be done by using the Split function, and using either the header names (if known beforehand) or newlines to split up the data. After separating the data, you can create new word application scopes to write to the 3 new Word documents. Unfortunately, selectors do not often work inside of Word, outside of working in the menus

Thanks for the Split String function. I was able to get the correct set of text from the Master doc (minus the Heading I used as the separator. I appended to a new word document, but the text is all in string text. There is no formatting. Is there a way to maintain this formatting through creating the new word doc?

I appreciate your quick response on my earlier question.

There are a few ways to do this, and they all have pros and cons.

The easiest way would be to figure out what each formatting should be, and applying that format by choosing a format, and then typing into word using the ‘type into’ activity.

Another option is to have a set template that has all the formatting already set, and then just replace the text in the template with the string that corresponds to that section with the Word ‘Replace Text’ activity.

The most complicated, but most reliable would be to copy and paste the entire document into each new word file. From here:
• Use the ‘Send Hotkey’ activity, and sending ctrl+F to open the search
• Type into the search the header of the section that you want in this word file
• Send hotkeys enter, then escape, then ctrl+shift+home, then delete
• Use the ‘Send Hotkey’ activity, and sending ctrl+F to open the search
• Type into the search the header of the section after the one that you want in this word file
• Send hotkeys enter, then escape, then ctrl+shift+end, then delete

This should have all the information you need in each of the resulting files. Something that you should keep in mind is that in the search function in Word (or at least the version of Word that I have) there is a maximum length of 255 characters. This shouldn’t be a problem if what you are searching is headers to sections, but it’s a problem that could pop up later if you try to adapt this into other workflows. Another thing you should keep in mind is that if the top header is not unique, you will have to go about this a bit differently, but I don’t want to make this any more complicated if we don’t need to.

1 Like

Jacob - Thanks for the solutions. I ended up using the “most complicated” with the hotkeys and it works very well. I truly appreciate your help.

How to enter text at the specified location in the word document

This is all working as expected, but I have one final requirement. The table at the beginning of the Master document has a name (text) that I need to use for the output word document I am creating. How do I pull the specific name (NameIWantToSelect) out of this table?


Thanks Jacob Sir, but i phase some problem on similar kind of task,

I’m using Resume/CV as “docx” file. And There is several blocks in this like Personal Info., Educational Info., etc, in this i want to extract only the block of Experience/Work Experience.

Process only that block and find experience and on which programing language it have the experience.

Could you please help me to solve this problem?

For more details,

Dhwanil - For my scenario I had Paragraph names in the word document that were standard for every document. I used hot-keys to find these (ex. "Paragraph Name Begin^p) to find the beginning and (ex. "Paragraph Name End ^p) Then selecting the text in-between to use. Since you say there is no specific pattern it will be difficult to narrow down the section you are looking for.

When I completed my project, I broke it down to how I would do the steps as a human in WORD and then just tried to duplicate these steps in UIPath.

Hope this helps.