ReplaceText

This activity assists the user in replacing existing text with new text in the specified
input Word document. It operates similarly to the “Replace” function in Microsoft
Word documents.

Technical Reference

INPUT

DelayAfter: It assists the user to add a delay before initiating subsequent activities.

The delay duration here is in milliseconds. By default, it is set to "1000" milliseconds.
When the option is left blank, the delay will not be considered.

DelayBefore: It assists the user in adding a delay before starting the execution of the activities.

The delay duration here is in milliseconds. By default, it is set to "1000" milliseconds.
When the option is left blank, the delay will not be considered.

FilePath: This parameter specifies to provide the “Path” of the input word file where the text needs to be appended.

 

You can either hardcode the values in the “String” variable or pass the values as “String” datatype.

 

This parameter accepts values in “String” datatype.

InputStringExisitng: This parameter specifies to provide the existing “input” text which needs to be found in the specified input word document.

 

You can either hardcode the values in the “String” variable or pass the values as “String” datatype.

 

This parameter accepts values in “String” datatype.

InputStringReplace: This parameter specifies to provide the new “input” text which needs to be replaced in the specified input word document.

 

You can either hardcode the values in the “String” variable or pass the values as “String” datatype.

 

This parameter accepts values in “String” datatype.

 

IsReplaceAll: This parameter enables to replace all the found existing text with the new text in the specified word document. Specify the "Boolean" value as "True" or "False."

 

True: Enables to replace all the text.

False: It replaces only the first found text.

None: If the option is left blank, the activity will, by default, behave as if "False" were chosen.

MISC

DisplayName: Displays the name of the activity. The activity name can be customized, which aids in troubleshooting.

SkipOnError: Specify the "Boolean" value as "True" or "False."

 

True: Continue executing the workflow regardless of any errors thrown.

False: Halt the workflow if it encounters any errors.

None: If the option is left blank, the activity will, by default, behave as if "False" were chosen.

Version: It indicates the version of the feature being used.

OUTPUT

Result: It provides the ability to view the execution status of the activity. It returns values in "Boolean."

 

True: Indicates that the activity has been executed successfully without any errors.

False: Indicates that the activity has been unsuccessful due to an unexpected error being thrown.

Represents mandatory fields to execute the workflow

Here's an example of how the “ReplaceText” activity works in the workflow –

The following is a simple example that demonstrates how to replace the existing
text with a new text in the specified word document.

1.       Create a solution for building a workflow.

2.       Drag and drop the "ReplaceText" activity onto the designer pane and set
it as the “Start Node.”

3.       Double-click the activity to provide the essential details.

a.       Here, I am providing the file path as the path of my word document to replace
the text.

i.      You can also choose the file path by browsing them using the “Three dots”
adjacent to the property.

b.       Next, moving to the “InputString” field to provide the existing text from the
specified word document.

i.      Here I am providing the input text as “Pleasant.”

c.       Now, moving to the “ReplaceWith” field to provide the new text that
needs to be replaced in the document.

i.      Here I am providing the input text as “Bad”.

d.       Navigating to the “IsReplaceAll” field in the properties to replace all the
found existing words in the document. Here I have specified the option
as “True”.

4.       Now, save and execute the workflow.

Use Case

A Supervisor needs to extract the report of their website, which is generated
through mail. After being extracted, these reports are transferred to a designated
folder for further processing. Upon downloading the report, it's essential to
replace a text from the word document.

The report has been extracted from their website, in which there will be wrong
replacement of words. Using the “ReplaceText” activity , we are going to replace
the word from the specified document and store it in a folder.

The following illustration demonstrates the process of downloading the report
and extracting the “Attachment” and “Received date” using the Email Automation
feature.

In this scenario, the input will be a “MailItem” that is specifically designed for
utilizing the “Email automation” feature. Using the email automation activities,
we will extract and store the word document. Subsequently, the extracted values
of the “Attachment” will be replaced and appended with a new text in the specified
word document using the "ReplaceText" and "AppendText" activity.

Steps to execute a bot

1.       Create a solution named “Report Extraction.”

2.       Now, drag and drop the “Create Directory” activity from the “FS Automation”
feature and set it as start node.

a.       This activity is used to create a folder in the specified path on the user’s
machine. Here are creating this folder to download the document from the
mail.

b.       Double click on the activity and enter the folder name as “REPORT” in the
“Name” property.

c.       Provide the “full path” where you want to create the folder.

3.       Place the “READ” activity from the Email Automation feature next to the
“Create Directory” activity.

a.       It helps to read the mail from the specified outlook account and store the
mails in the “MailItem” in a list format.

b.       Double click on the activity and enter the “Account Name” as “YourMailID”
in the property.

c.       Specify the “YourMailID” in the “FolderName” property as well. This property
is used to integrate with the account name provided.

d.       Navigate to the properties and specify the “No.of.Mails” as “1” for the activity
to read the number of mails from the specified outlook account.

e.       Set the “SortBy”  field as “Ascending” from the drop-down to sort and read
the mails in ascending order.

f.        Choose the “SortByFieldName” as “ReceivedDate”  from the drop-down to
sort and read the mails with the received date in ascending order.

g.       Enter the “SubFolderName” as “Inbox” in the property to choose the folder
name from which the mails has to be read.

h.       Specify “True” in the “Unread” property to read only the mails which has
not been read.

i.         Declare a variable as “Read_ml” in the “List” property and press “CTRL+Q”
to store the read mails in a variable for further processing. It will be used as
input in other email activities.

j.         Click here to see how to declare a variable with “Mailitem”.

4.       Place the “For each” activity next to the read mail to iterate each mail from the
“Read_ml” variable for further process of saving the report and extracting the
values.

a.       Enter "Read_ml" as the input value here, in which is where we have stored
the read mails.

b.       Now, the values from "Read_ml" have been assigned to the "Item."

c.       Select "MailItem" as the "TypeArgument" since it's a list of mailitem.

5.       Drag and drop the “ExtractMailMessage” activity inside the “For Each” activity.

a.       Navigate to the properties and provide the “AttachmentPath” as the folder path
to extract and store the report from the mail.

b.       Choose the “InputType” as “MailItem” from the drop-down as we are using the
“item” variable as input here.

c.       Specify the “MailItem” as “item” here to extract the values from the mail using
the variable.

d.       Declare a variable in the “ReceivedDateTime” as “RDT” to extract the received
date and time from the mails.

i.            There are two methods to create a variable –

ii.            Method 1 – Click on the " ReceivedDateTime " property within the
"ExtractMailMessage" activity and enter the variable name. In this case, we are
using " RDT." Then, press "Ctrl+Q," which is a shortcut key to create a variable.

iii.            Method 2 - Click on the Variables pane and enter the name " RDT." Then, in
the "Variable Types" column, select "Browse for Types" from the dropdown menu.

iv.            The .Net window for data types will appear on the screen, enter the type name
as “System.DateTime” and then click on “OK” button.

6.       Now, place the “WriteLog” activity next to the ExtractMailMessage activity.

a.       Here we are using this activity to print the received date and time from the
extracted mail item.

b.       Enter the “Input” text as “RDT.ToString” in the box.

c.       The “.ToString” is advised to use along with any other data types other than
string format. It converts any data type into string.

d.       Enter the log level as “Info”.

7.       Drag and drop the “GetFolderInformation” activity to workflow.

a.       It helps to extract the specified folder information. Here we are using this activit
y to get the file name extracted from the mail.

b.       Enter the folder path as the path created above.

c.       Declare a variable in the “Files” as “Filename” to extract the name of the file.

i.            There are two methods to create a variable –

ii.            Method 1 – Click on the " Files " property within the "GetFolderInformation"
activity and enter the variable name. In this case, we are using " Filename."
Then, press "Ctrl+Q," which is a shortcut key to create a variable.

iii.            Method 2 - Click on the Variables pane and enter the name " Filename."
Then, in the "Variable Types" column, select "Browse for Types" from the
dropdown menu.

iv.            The .Net window for data types will appear on the screen, enter the type name
as “System.Collections.Generic.List<String>” and then click on “OK” button.

8.       Next, place the “ReplaceText” activity next to the GetFolderInformation activity
in the flow.

a.       It helps to replace a specific text or sentence from the specified word document.

b.       Double click on the activity and provide the filepath as the folder path where we
have stored the word document.

i.            Here I have mentioned it as “FolderPATH”+ “/” + filename(0) in the “FolderPath”
box.

c.       Next, moving to the “InputString” field to provide the existing text from the
specified word document.

i.            Here we are providing the input text as “RoboticProcessAutomation.”

d.       Now, moving to the “ReplaceWith” field to provide the new text that needs to be
replaced in the document.

i.            Here we are providing the input text as “HyperAutomation”.

e.       Navigating to the “IsReplaceAll” field in the properties to replace all the found
existing words in the document. Here I have specified the option as “True”.

9.       Then, place the “AppendText” activity to the workflow.

a.       It helps to add an additional text to the specified word document. Here we are
using this to add a heading to the word replaced word document.

b.       Double click on the activity and provide the filepath as the folder path where we
have stored the word document.

i.            Here I have mentioned it as “FolderPATH”+ “/” + filename(0) in the “FolderPath”
box.

c.       Next, moving to the “InputString” field to add an additional text to the  specified
word document.

i.            Here we are providing the input text as “Replaced Document.”

d.       Navigating to the “AtTop” field in the properties to write the text at the top of the
document as we are adding this as a heading. Here I have specified the option
as “True”.

e.       Next, moving to the “NewLine” field in the properties to write the text in a new
line at the top of the document. Here I have specified the option as “True”.

f.        Moving to the “Result_Msg” property in the output section to declare a variable
to view the output.

i.            There are two methods to store the spied value in the variable.

ii.            Method 1: Double-click on the variable parameter in the “Output” section
and enter a name that helps you easily identify it in the flow. Here, I'm using
the name "Result" and using the shortcut key "Ctrl+Q" to create the variable.

iii.            Method 2: Click on the variable pane, enter your preferred name
(here, I'm using "Result"), and choose the data type as "String" since the output
value accepts the string data type.

10.   Now, save and execute the workflow.

The bot will execute the workflow and initiates to create a folder to save the document.
Then proceeds to extract the word document from mail to replace and append the text
in the word document.

Below is the sample of the output.