How to fill form in word application by getting data from excel

I would like to fill the form and the required data is stored in excel, I have to fill data to the relevant position, please give solution to how we can achieve it.

can i have a view on the word application form if possible, that would help us to go in the right direction
Cheers @DivyaT

Hi @DivyaT

can you share the forum and excel screen shots so that we can explain more clearly…
–as it understood first read the excel file you will get datatable and then loop through that datatable and then fill the forum… (233.8 KB)

This is my word template

Dynamic_Reporting_Word_Template (2).zip (240.2 KB)

This is my word template and excel data.

kindly follow the below steps that could solve your issue

  1. use excel application scope and pass the file path as input
  2. use read range activity to read the data in excel and get the output of his activity with variable named outdt of type datatable and mention this in output property
  3. use a for each row activity and pass the above variable outdt as input
  4. inside the for each row activity use a word application scope (which can be obtained from manage packages in design menu of your studio and go to official tab and type word, where download the uipath.word.activities and install it)
    and once after downloading use the word application scope activity inside this for each row loop…and pass the word file path as input to this activity
  5. inside this word application scope, use replace text activity from same word activities
    list from the activity panel and pass the search property as “F2” and mention the Replace property as row(“Client Name”).ToString, where row is the variable obtained from for each row loop, as we still inside the for each row loop, and structure is excel application scope, read range, for each row loop, word application scope, replace text…
    like use n number of replace text activity and mention the search property with the text found in your word template and replace property with row(“yourcolumnname”).ToString

Cheers @DivyaT


Thanks for the reply,I will check and let you know.

Cheers @DivyaT

I can able to fill only one set of values i mean after filing form the word automatically saving , n further its not able to identify the replaced element.

1 Like

I have attached a main file. See if it helps. Only thing you have to do is use copy file activity. Let me know if it (12.1 KB)

ok i will check and let you know.

First let me tell you why we weren’t able to go for the next word file, while able to process the first one…actually i was expecting that and just now about to make some changes in the previous comment, no worries
as the word application scope will save the file once after all the activities been executed…the old word file get updated with these new replaced words and got saved…so while trying to open the same word in the next iteration of for each row loop we wont be able to see F2, L2, A2 or the keywords that were there actually, as they got changed now with the excel value, So, kindly follow the below steps that could help you resolve this buddy…
–before using word application scope we need to use a assign activity and a copy file activity followed by that and mention like this

  1. assign activity, outdestination_path is a variable of type string
    outdestination_path = “yourfilepathwithout.docx”+now.ToString(“hh_mm_tt”)+".docx"
  2. in copy file activity
    in path property = "the file path of your word file"
    in destination property = outdestination_path
    and after this use the word application scope and in the file path input property mention this with the above created variable outdestination_path
    then do the same with what were suggested before

NOTE : the reason of this is “yourfilepathwithout.docx” is we need to include some timestamp to enable the word application scope to save the new file with different name (different time period as name) and open them the same, so we are trying to concatenate the timestamp as a string to the previous file name and then we are concatenating the extension as +".docx"
Kindly try this and let know buddy
Cheers @DivyaT

did that work buddy @DivyaT

I will check n update you

1 Like

sure @DivyaT

Hi , Thanks for the suggestion the mentioned code is working fine , now the thing is in color code section , i have to modify the word with specified color like color is red means i should format the word red with red color.Any suggestion would be helpful.

Hi, Thanks for the suggestion the mentioned code is working fine.

1 Like


Kindly close this topic buddy with the right comment marked as solution that could help others looking for ideas under your topic
Cheers @DivyaT

But I have one more doubt, now the thing is in color code section, I have to modify the word with specified color like the color is red means I should format the word red with red color. Any suggestion would be helpful.

1 Like

This is my expected result.

This is syntax i have checked in forum,bu i have color details in excel based upon color i have to format but i dont know how to use excel column name in (your color) place.
System.Drawing.Color.(yourColor) e.g. System.Drawing.Color.Green

I hope now atleast i will get some suggestion

1 Like