Code Stage - Copy a table from a word document if it contains a string

sinsation

New Member
Hello everyone,

I have a process step which requires me to search for a string (Customer Name) in a word document (Contact Information Sample.docx). If the Customer Name is present in one table (there are several tables, each represents a contact), then the whole table should be copied to the clipboard so that it can be pasted inside a another word document (Appendix 1 Edited.doc) at a specified location (red square in picture).

A note, Appendix 1 Edited, already has pre-defined tables (highlighted in yellow) where customer data (Electricity Trading Company 1 and Electricity Trading Company 2) can be set directly to using an Action Stage and Set Table Cell. In the manual processes the worker is opening the contact information document, searching for the customer and copying the corresponding table from contact information document. They are then pasting it into Appendix 1 edited and removing the pre-defined tables. The process is done twice, once for electricity company 1 and once electricity company 2.

I have looked at the actions inside the MS Word VBO and I think it should be manageable using VBA scripting however I can't get it to work. Resources I have looked at.

Does anyone know a good way to solve this problem using code stage or a combination of a code stage and action stage? I have added two pictures, and a link to for the documents. Pictures and Documents

I think there are two options that comes to mind.

Option 1 using VBA:
Code Stage - Get Contact Information
Open the customer Information document, search for the customer name, if it is present in one of the contact tables then copy that table to the clipboard.
Code Stage - Add Contact Information To Appendix 1 Edited
Open Appendix 1 Edited, and paste in the table at a given location between the two tables.
Code Stage - Remove Table
Remove the empty pre-defined table in Appendix 1 Edited.

Repeat the steps to get contact information for both companies.

Option 2 using VBA together with Action Stage:
Code Stage - Get Table Number
Open Customer Information document, search for the customer name, if it is present in one of the tables then get the table number.
Code Stage - Read Table as a Collection
Use the table number in an action that reads the table as a collection.
Action Stage - Set Table Cell
Open appendix, then use action Set Table Cell to edit the pre-defined tables.

Repeat the steps this to get contact information for both companies.

Thanks in advance!e
 

Attachments

  • Appendix 1 Edited.PNG
    Appendix 1 Edited.PNG
    43 KB · Views: 17
  • Contact Information.PNG
    Contact Information.PNG
    35.7 KB · Views: 15
Top