# Dynamic excel name and folder

**URL:** <https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935>\
**Category:** Help\
**Tags:** file-system, question, excel, activities\
**Created:** [December 30, 2019, 4:53am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935 "2019-12-30T04:53:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpatil](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@rpatil](https://forum.uipath.com/u/rpatil)\
**Post date:** [December 30, 2019, 4:53am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/1 "2019-12-30T04:53:02Z")

</div>

Hi All,

I have a scenario where the excel directory and excel name is dynamic so i how do i pass the value in excel application scope.

---

<div class="post-metadata">

**Author:** ![Manish540](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/manish540/32/356167_2.png) [@Manish540](https://forum.uipath.com/u/Manish540)\
**Post date:** [December 30, 2019, 4:56am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/2 "2019-12-30T04:56:01Z")

</div>

Whether you are downloading the files and storing it some where?..

---

<div class="post-metadata">

**Author:** ![rpatil](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@rpatil](https://forum.uipath.com/u/rpatil)\
**Post date:** [December 30, 2019, 4:57am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/3 "2019-12-30T04:57:13Z")

</div>

No , file will be present before itself

---

<div class="post-metadata">

**Author:** ![mukeshkala](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mukeshkala/32/523935_2.png) [@mukeshkala](https://forum.uipath.com/u/mukeshkala)\
**Post date:** [December 30, 2019, 4:57am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/4 "2019-12-30T04:57:22Z")

</div>

1. Take a String variable : strExcelPath

2. assign strExcelPath value as seen in below screnshot

StrFileLocation : Location of excel  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/2/5/252ba4ca915b8afc6cc6627f1f6c40861f6a1f4a.png)

1. Pass strExcelPath into Excel application scope  
_–_  
_Mukesh_

---

<div class="post-metadata">

**Author:** ![rpatil](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@rpatil](https://forum.uipath.com/u/rpatil)\
**Post date:** [December 30, 2019, 5:02am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/5 "2019-12-30T05:02:26Z")

</div>

Thank you i will try and one more thing is file name ends with year and previous month so how to pass that value . For example its will be  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/1/e/1eb711520898d301e7a274677ee7c779f86094eb.png)

---

<div class="post-metadata">

**Author:** ![Manish540](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/manish540/32/356167_2.png) [@Manish540](https://forum.uipath.com/u/Manish540)\
**Post date:** [December 30, 2019, 5:16am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/6 "2019-12-30T05:16:21Z")

</div>

Get the filename from the directory and apply the regex to get month year for the filename .  
Use this below regex to get the “201910” from the filename,  
“\d{0,}”  
To add it use below code of @ImPratham45 or @Palaniyappan

---

<div class="post-metadata">

**Author:** ![ImPratham45](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/impratham45/32/161516_2.png) [@ImPratham45](https://forum.uipath.com/u/ImPratham45)\
**Post date:** [December 30, 2019, 5:19am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/7 "2019-12-30T05:19:55Z")

</div>

“Monthly Report format\_”+Date.Now.AddMonth(-1).Tostring(“yyyyMM”)+“.xlsx”

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [December 30, 2019, 5:20am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/8 "2019-12-30T05:20:46Z")

</div>

Hi  
Hope these steps would help you resolve this  
—in a assign activity mention like  
**arr\_files = Directort.GetFiles(“yourfolderpath”,”Monthly Report format\_\*.xlsx”)**

Where arr\_files is a variable of type array of string  
—now pass this as input to FOR EACH activity and change the type argument as string in the property panel  
—inside the loop use EXCEL APPLICATION SCOPE and mention the input as **item.ToString**

Or

If we need only the latest file from the folder with the report dated

To get the latest file alone

**Str\_input = Directory.GetFiles(folder\_path,“Monthly Report format\_\*.xlsx”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToList(0).ToString** Now pass this as input to Excel application scope

Cheers @rpatil

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [January 2, 2020, 5:20am UTC](https://forum.uipath.com/t/dynamic-excel-name-and-folder/180935/9 "2020-01-02T05:20:49Z")

</div>

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