Replace text Version 1 (Python)

Action group: Office


Description

The action replaces all occurrences of a string in the document with another string

Action icon

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ContextContext for working with a documentRobin.OpenTextDo c
Yes
ReplaceThe text to be replacedRobin.String
Yes
OnThe new value for the text to be replacedRobin.String
Yes
Replace matchSelecting the appropriate value will replace all matches or just the first oneRobin.String
Yes

Special conditions of use

None.

Example of use

Task 

There is a file test.docx with a list of names.

It is necessary to open the document and replace the name Maria with the name Olga. Next, save the document and close it. 

Solution

Use the "Open", "Replace text", "Save", "Close" actions.

Implementation

  1. Assemble a robot scheme consisting of the actions: "Open", "Replace text", "Save", "Close". 
  2. Set the "Open" action parameter. 
    In the "Path to file" field specify the path to the file test.docx
  3. Set the parameters for the "Replace text" action: 
    In the "Context" field, specify the context created in step 1
    In the "Replace" field specify the value to be replaced.
    In the "On" field specify the new value.
    In the "Replace match" field, specify the first match. 
  4. Move the "Save" action to the workspace and set its parameter.
    In the context field specify the context of the open document.
  5. Move the "Close" action to the workspace and set its parameter.


  6. Click "Start" in the top panel.

Result

The program robot completed successfully.

The required text in the document is replaced. The file is saved and closed.


  • Нет меток