Iterating through folders and reading and editing excel files

Hello guys,

I am creating a project where you should be extracting attachments (excel files) from outlook and save it in a folder so later on you can edit them and do other tasks. Well, I have downloaded the attachments and saved them in Attachments folder by their Employee IDs ( a folder which contains excel files for that particular employee) but the problem is that I have to now iterate through the Attachements–>EmpID–>Excel files to read each excel file in order to do some sum and other tasks. How do I achieve this?

Please help.


We can use a simple assign activity to get all the excel files from we want in specific
The steps involved are as follows
—use a assign activity like this
Out_filepath = Directory.GetFiles(“yourfolderpath”,”*.xlsx”)
Where Out_filepath is a variable of type string array

—now use a for each loop activity and pass the above variable as input and change the type argument as string in the property panel of for each loop activity
—now use a excel application scope and mention the filepath as item which is the variable from for each loop which will have the file path we want

Simple isn’t it
Cheers @Tanveer_Shaikh


Hey @Palaniyappan, Thank you for your quick help. But the thing is that I am confused as to how one should get to those files from folders which is saved in another folder.

For example: Attachments\ed1\someex1.xlsx , Attachments\ed1\someex2.xlsx, Attachments\ed1\someex3.xlsx, Attachments\ed1\someex4.xlsx

Now I have to get those excel files so that i can edit them and save new excel file anywhere i want.

Thanks again for your help.


The expression is
Out_filepath = Directory.GetFiles(“Attachments\ed1”,”*.xlsx”)

This will store all those excel files file path in that Out_filepath as a array of string

Then we can pass this as a input to for each loop and there change the type argument as string
—inside the loop use excel application scope and mention the file path as item

cheers @Tanveer_Shaikh


Thank you very much @Palaniyappan, you are a great help! I will try this now.


No worries
Kindly try and let know for any queries or clarification
Cheers @Tanveer_Shaikh

1 Like

Hi @Tanveer_Shaikh

If you want to use a template for this scenario, you can follow this…

Hope it helps


Hi @Palaniyappan, that works. I forgot to mention that ed1 is not constant. I have saved folders by employee id’s. how do I attain this. I have saved ID’s in a variable and tried using that as follows but doubtful if it will work:


Thanks in advance.

1 Like

Thank you @Lahiru.Fernando, I have already downloaded your workflow and it is impressive. I will use it later in the project and will let you know if there are any questions.


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