MS Word
Studio Pro activities > MS Office > MS Word. Includes "Read Word file", "Write Word file", "Append to Word" and "Replace Words in Template".
Activities
Read Word file | Write Word file |
---|---|
Reads the content of a Word file | Overwrites the content of a Word document |
Append to Word | Replace Words in Template |
Appends data to a Word document | Replace words in a Word file with the desired values |
Read Word file
Description
Reads the content of a Word file. The 'Save value to variable' activity appears automatically when choosing the 'Read Word file' activity. It automatically saves the value to a variable. However, the activity is not mandatory to use and can be removed from the workflow.
Parameters
Path
- Set a value: enables you to directly write the desired path. Clicking the 'Pick' button allows you to manually choose the path. The file extension must be '.docx'.
- Save the previous step result: chooses the previous activity result as a path.
- Calculate a value: enables you to use available properties and methods to form a path.
Supported formats:
- docx
Comment
Contains an annotation to the activity. The input text will be displayed above the activity name.
Result
The Word document data is stored in the word_content variable by default. This variable represents a string which may contain text formatting rules. For example:
<p><strong>Sample Document</strong></p><p>\\tThis text will be written by the <em>robot</em>. </p><p></p>
Write Word file
Description
Overwrites the content of a Word document. If the document doesn't exist, then the robot will create a new file automatically.
Parameters
Path
- Set a value: enables you to directly write the desired path. Clicking the 'Pick' button allows you to manually choose the path. The file extension must be '.docx'.
- Save the previous step result: chooses the previous activity result as a path.
- Calculate a value: enables you to use available properties and methods to form a path.
Value
- Set a value: enables you to directly specify the text to write.
- Save the previous step result: chooses the previous activity result as the text.
- Calculate a value: enables you to use available properties and methods to form a text.
This activity supports some HTML-tags:
- Paragraph:
<p>Paragraph text</p>
- Bold text:
<p> <strong>Bald text</strong> </p>
- Italic text:
<p> <em>Italic text</em> </p>
- Headers:
<h[1-6]>Header text\</h[1-6]>
- Tables:
<table> <tr> <td>Table cell text</td> </tr> </table>
Comment
Contains an annotation to the activity. The input text will be displayed above the activity name.
Append to Word
Description
Appends data to a Word document. If the document doesn't exist, then the robot will create a new file automatically.
Parameters
Path
- Set a value: enables you to directly write the desired path. Clicking the 'Pick' button allows you to manually choose the path. The file extension must be '.docx'.
- Save the previous step result: chooses the previous activity result as a path.
- Calculate a value: enables you to use available properties and methods to form a path.
Text
- Set a value: enables you to directly specify the text to append. The text may contain formatting rules, for example,
<p><strong>Test Document</strong></p><p>This is a sample text</p>
- Save the previous step result: chooses the previous activity result as a text.
- Calculate a value: enables you to use available properties and methods to form a text.
Comment
Contains an annotation to the activity. The input text will be displayed above the activity name.
Replace Words in Template
Description
This activity replaces words in curly brackets in a Word file with the desired values.
Supported file format - .docx.
Parameters
Path to file
- Set a value: allows you to set a path to a word file manually. Click on the “PICK” button to specify the path.
- Calculate a value: allows you to use a special formula or a special method to specify a file path.
- Save the previous step result: takes the result of the function from the previous workflow step as a file path.
Substitution map
Create a dictionary containing the words to substitute and the substitutions themselves. For example, if a word file contains words {{name}} and {{surname}}, which you want to replace with real values, for example, 'Jack' and 'Smith', the substitution map will look like this: {'name': 'Jack', 'surname': 'Smith'}.
- Calculate a value: allows you to use a special formula or a special method to set a substitution map.
- Save the previous step result: takes the result of the function from the previous workflow step as a substitution map.
Note
If you face any issue while using the activity related to the size of the file or the number of characters it contains, you can attempt to split the file and try again.
New file path
- Set a value: allows you to set a path to a new word file manually. Click on the “PICK” button to specify the path.
- Calculate a value: allows you to use a special formula or a special method to specify a new file path.
- Save the previous step result: takes the result of the function from the previous workflow step as a new file path.
If the "New file path" parameter is not specified, the file from the "Path" parameter will be overwritten.
Comment
This parameter allows you to create an annotation for the activity. The input text will be displayed above the activity name.
How to use it?
When working with documents, there is a common necessity to have a template file where you need to substitute the required values and save them as a new file. This activity allows you to automate this routine - all you need to do is to prepare the template file and configure the bot to substitute the values in this file.
Updated over 1 year ago