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 fileWrite Word file
Reads the content of a Word fileOverwrites the content of a Word document
Append to WordReplace Words in Template
Appends data to a Word documentReplace 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

  1. 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'.
  2. Save the previous step result: chooses the previous activity result as a path.
  3. 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>

⬅️

Back to the top


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

  1. 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'.
  2. Save the previous step result: chooses the previous activity result as a path.
  3. Calculate a value: enables you to use available properties and methods to form a path.

Value

  1. Set a value: enables you to directly specify the text to write.
  2. Save the previous step result: chooses the previous activity result as the text.
  3. Calculate a value: enables you to use available properties and methods to form a text.

This activity supports some HTML-tags:

  1. Paragraph:
    <p>Paragraph text</p>
    
  2. Bold text:
    <p>  
     <strong>Bald text</strong>  
    </p>
    
  3. Italic text:
    <p>  
     <em>Italic text</em>  
    </p>
    
  4. Headers:
    <h[1-6]>Header text\</h[1-6]>
    
  5. 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.

⬅️

Back to the top


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

  1. 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'.
  2. Save the previous step result: chooses the previous activity result as a path.
  3. Calculate a value: enables you to use available properties and methods to form a path.

Text

  1. 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>
    
  2. Save the previous step result: chooses the previous activity result as a text.
  3. 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.

⬅️

Back to the top


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

  1. Set a value: allows you to set a path to a word file manually. Click on the “PICK” button to specify the path.
  2. Calculate a value: allows you to use a special formula or a special method to specify a file path.
  3. 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'}.

  1. Calculate a value: allows you to use a special formula or a special method to set a substitution map.
  2. 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

  1. Set a value: allows you to set a path to a new word file manually. Click on the “PICK” button to specify the path.
  2. Calculate a value: allows you to use a special formula or a special method to specify a new file path.
  3. 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.

⬅️

Back to the top