How to create a dynamic folder using a variable

Hi I need to read cells in a column in an excel file which contain the words “apple”, “orange” “pear” etc and create folders named “apple”, “orange”, “pear” etc. I use
workbook read range,
for each row in DataTable,
assign keyword = row.item(“fruits”)
{I created a variable called “keyword”, “fruits” is my header for this column inside the excel file}
Create Folder using the path “C:\FolderA”+keyword
I got this error

“RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.
at UiPath.Core.Activities.ForEach`1.StartLoop(NativeActivityContext context)…”

I believe it is the way i wrote the path. What is the correct way? Anyone kindly enlighten? Thanks a lot.

Hi @surferkw

Welcome to the UiPath Community.

Try like this



since you have excel file you don’t need Build Data Table Activity.
in your case use read range for reading the excel file and storing the data in a data Table variable which will be used inside for each data row (inpuDT)

Attached xaml file

Create Folder.xaml (7.1 KB)

Hi Kumar,
Thanks a lot for your very prompt response. You are right, I need not build datatable since i m using an excel file. I realise my mistake, it is omiting a “” after “FolderA”. I also find that I can still create the folders without the “.ToString” after the “keyword”. Really appreciate your help.


Mark the solution to close the topic.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.