Set Bookmark Content

Hi Uipath Users,

I hope that anyone can help me:). I have an excel file with 6 different columns and 10 rows. I also have a Word pdf which contains a letter that I have to send to customers. Now inside these letter the values of the excel file columns (e.g Name, SalesOrder, Delivery address) need to be filled in for every row. So i need to get 10 pdfs of this letter with all the values from the excel filled in automatically on the right places insight the letter (So the name of the first row should be filled in on the Name place in the letter and the SalesOrder of the first row has to be filled in in the Salesorder place of the letter etc). Now i’m trying to do that with Set Bookmark Content but how am I able to do that for each row automatically? Now I just have to fill in the word I want to change and the text I want to replace it with.

Thanks in advance!


Hi and welcome to the community!
The first thing you should do, is try setting the bookmarks manually, after you do that, then you work on the loop for the dynamic part. What could you do so far?

Hi @Hakimi,

Welcome to UiPath Community !

Where you want to set book mark ? Excel or Word…


Thanks for your response !! Do I set them manually with set bookmark content as well? because there they ask the Bookmark Name and Bookmark Text? and for the text I want to have the values from the columns?
Thank you!

In word! and I want to use the values form the excel file to fill it in with

Yes, just to test, you do one with fixed values, without excel. If all goes well, then you do the dynamic part of the project.

Yes that goes well! it changes the value in word! But I can’t figure out how to make it dynamic, how can I make sure it fills in the value of each row in the bookmarks of a different word document? So Name, Salesorder, Product etc of row 1 in bookmarks of word document 1, then Name, Salesorder, Product etc of row 2 in bookmarks of word document 2, and so on…

You need to have an excel file first with all information you need, them you will use Read Range to bring the data to UiPath, after you will use For Each Row and inside you need the logic to be able to do that, if you start, we help you where you have doubts.

Yes I did that already, I used excel application scope and read range and made a datatable with all the columns. Then I used for each row and inside the body I put the word application scope and then I selected the right filepath and then my thought was using Set Bookmark Content activity but I can only put in a string or a variable, not a specific column of that datatable? That’s where i’m stuck at the moment, I tried using read column acitivity and create a variable from that but than I have to do that manually for all the columns.

Thank You!

H @Hakimi
try excel application scope and use select range on the data and use send hot key as ctrl+k

ashwin S

use row(“Column Name”).ToString to get values from excel, when inside the For Each Row.

Thanks! I’m insight for each row and I entered row(“Column Name”).ToString in the Bookmark Text and then for the first one row it fills in the bookmarks but then it stops and it gives an error and says that the bookmark is not found? but i’m inside the each row activity !

You understand you can use either the name of the column inside the row() or the position in the excel, like row(0).ToString if it is the first column…

yes I used the name of the column not the position!

when i use row(0).ToString it does the same, enters the first one in the bookmark and after that it gives the error bookmark not found!

Well i dont know the names of your bookmarks, is it the same as the columns in your excel?

I think I know what the problem is, It only opens one word document, so it changes the bookmark and then it tries to look for the bookmark again but it is changed with the first name so the bookmark is not there anymore. I’m looking for an activity which opens the word document but I can’t find one except then the word application scope (which is inside my For Each Row activity). Is there another one? Thank you!

1 Like

You should have the Word Scope outside the foreach, or it will open and close everytime you change excel row…

Here you go with an xaml
hope this would help you (37.7 KB)

run the file to get the output sample

Cheers @Hakimi

but if i put the word scope outside the for each the bookmark content is not in the for each as well, because that needs to be inside the word scope , so it does not fill in the value of each row