How can I automictically change files that contain values that is in dictionary.
E.g. I have a key which is and value “ABC”, and a few docx how do I change to “ABC” if the key exist in one of these files and if so there is multiples same in a file so how do I change all same at once.
It is not a dictionary implementation and maybe a bit more requirement was handled than what was needed, but it does explain about the looping with Key-Value replacement being done in the Word document or the Word document copy.
Let us know if it was possible for you to shift to the Dictionary implementation or if it is not the required logic would request if you could provide the Sample Input documents and the Expected output required, we should be able to implement in a similar manner.
If the identifier on left is present in the docs…then use for eqch row in datatable or excel and then for each file in folder…then use word file activity and inside it replace text activity …
This will check for eqch identifier if the required value is present in word it would replace
If you could provide us with the Sample documents on what is available to you as Inputs and what is the Transformation or output needed, we would be able to help you faster.
An initial idea was providing in the workflow provided.
The Input documents are placed in Input Files folder, After Execution it creates another Folder called as Output Files and will have the updated documents in it.
Since the Datatable or the Excel sheet was also arranged in a Dictionary (Key-Value pair) manner, we didn’t have to convert it to a Dictionary again, as each row in the Excel sheet is as same as one Key-Value pair in Dictionary, we could loop through the rows present in the Excel sheet one by one and perform the substitution, this is also assuming that all the Keys present in the Excel is Unique.
Reading the Master Excel sheet and getting the Output as Datatable (DT) and creating the Output Files folder. So that we can keep the input files as is and create separate output files in a different folder.
Next, We are looping through the Input Files folder using For Each File in Folder activity and fetching only files with extension as .docx
Inside the For Each File in Folder activity, each file is retrieved and we are preparing the OutputFilePath variable value and copying the input file to the Output file path location.
Next, we are looping through the rows of Master Excel Datatable and using the Replace Text in Document activity to perform the replace of Placeholders in Document which is present as keys in Master Excel sheet with the Mapped Values column.
Taking the below as a Small Example :
Each row/CurrentRow variable value will have the set data mapped {Key,Value}, so the Value Corresponding to the Key <COMPANY NAME> will be 1, and it is accessed by CurrentRow("Value").ToString.