How to use MS Word - Mailings - Select Recipients - Use an existing list option in Pega Robotics automations

Hi,

I need to add some records (from excel/txt file) inside my MS Word document (word template) by using - Mailings - Select Recipients - Use an existing list option. Could anyone please let me know how we can do this through Pega Robotics automations.

Thanks & Regards

Chettiannan.P

@Chetti Adding data to a Word document and reading from Excel are certainly possible using Robotic automation, however I believe Word can source data directly from an external file natively. The best solution here would be to use the native methods in Word to do this, probably through a Macro. If you wanted the document to remain as/is, this would be the best solution.

If you did want to use Pega Robotic automation to perform a similar function, you wouldn’t trigger that exact function in Pega Robotics, though since Pega Robotics does not interact directly with the Word document UI. Interactions with office documents are done through the interfaces to them. To do this, you would insert bookmarks into your Word document template and load that into the Word connector. Afterwards, the properties for the connector will show each of the bookmarks that you can then set in an automation. You would need to write some logic to read from your Excel file or text file and iterate through it to update the bookmarks of the current Word document. You’d then save it and perform the update for the next record, etc.

You can also use a hybrid approach. For this, you would create a macro using native Office tools that performs the functions you wish, and then invoke that macro from a Word connector.

@ThomasSasnett Thank you for the information

@Chetti I should mention that it is possible to do this within a script (and technically translate that script to the automation surface). If you were to search other sites for information on how to perform a mail merge using C#, you could certainly apply that into a script to be executed from Pega Robotics.

@Chetti

Step-by-Step Guide

  1. Start Pega Robotics Studio: Open Pega Robotics Studio and create a new project or open an existing one.

  2. Add Microsoft Word Application:

    • Add a new Windows adapter to your project and configure it to interact with Microsoft Word.
    • Launch the Word application and use the Windows Interrogation tool to capture the elements within Word that you will interact with.
  3. Interrogate Elements:

    • Interrogate the “Mailings” tab in the Word ribbon.
    • Interrogate the “Select Recipients” button in the “Mailings” tab.
    • Interrogate the “Use an Existing List” option that appears in the dropdown when you click “Select Recipients”.
  4. Configure Automation:

    • Create an automation sequence that clicks on the “Mailings” tab.
    • Add a click event on the “Select Recipients” button.
    • Add another click event on the “Use an Existing List” option.
  5. Select File:

    • After clicking “Use an Existing List”, a file dialog will appear. You need to automate the selection of the file.
    • Interrogate the file dialog components (e.g., file path text box, open button).
    • Add automation steps to input the file path into the file dialog’s text box and then click the “Open” button.

Detailed Example Automation

  1. Add Windows Adapter:

    • Right-click on your project, select Add New ItemWindows Adapter.
    • Configure the adapter to attach to the Word application.
  2. Interrogate Word Elements:

    • Start the Word application and switch to the Interrogation mode in Pega Robotics Studio.
    • Capture the “Mailings” tab: Click on it and assign it a unique control name.
    • Capture the “Select Recipients” button in the “Mailings” tab.
    • Capture the “Use an Existing List” dropdown option.
  3. Create the Automation:

    • In the automation designer, drag the captured “Mailings” tab control to the canvas and add a Click method.
    • Similarly, add Click methods for the “Select Recipients” button and the “Use an Existing List” option.
    • Interrogate the file dialog:
      • Capture the file path text box in the file dialog.
      • Capture the “Open” button in the file dialog.
    • Add an automation step to set the file path in the text box and click the “Open” button.
  4. Sequence of Steps:

    • Click on “Mailings” tab.
    • Click on “Select Recipients” button.
    • Click on “Use an Existing List” option.
    • Set the file path in the file dialog.
    • Click on the “Open” button in the file dialog.