How do I change Datatable to Dictionary,

as I want to change values in word doc using excel value which are in columns instead of rows

Check this out to convert datatable to dictionary


But how do I implement it to change the word doc values to values in dictionary


Can you please explain what you want to acheive


In my screenshot the first column is key and second is value, I have a word document that has the key which i want to change it to value, e.g. first row, in word doc has so I want to change it to ABC PTE LTD. usually datatable is for first row as header but now my header is in first column. Do help me out Thank You!


  1. Read the datatable
  2. Use lookup datatable…depending on the first column and look p for what key you want to replace…which gives the valued from column2
  3. Now use the same key again in replace text activity in word to replace the tag with actual value


is it possible to use dictionary if so how? as my teacher said to use datatable to dictionary is more efficient do help me out Thank You!

  • For Each Row in Data Table
    ** Assign yourDict(CurrentRow(“key column name”).ToString) = CurrentRow(“value column name”).ToString

Maybe the following is fitting

Prepare the Word File / Template with dedicated Placeholders e.g. #CompanyName#

Bring DataTable to Dictionary / or iterate over the DataTable

Use one column for the placeholder
Use other column for the value

Then with the help of Search / Replace within the word you can set values by using the Placeholder for the search

DT - to Dictionary:
Assign Activity:
dictLK | Dictionary(Of String, String) =

dtData.AsEnumerable.ToDictionary(Function (x) x(ColNameOrIndexKey).toString.Trim,Function (x) x(ColNameOrIndexValue).toString.Trim)

Also have a look here: