Need help with Excel sequence

Hi,
I am reading data from a worksheet and writing the data into a new file. My question is how can I change my output file name every time I run the sequence? how can I keep the old output file and create a new one when I run the sequence again?
Thank you.

Does your output file have different requirements? Like is it a daily run and you need to make the date?

If so you could do something like “Daily Run”+now.tostring or something in your output variable.

You can save you dynamic file name in a variable and yes you can use this

"FileName"+DateTime.Now.ToString+".xlsx"

Thanks,
Prankur

1 Like

It’s a weekly run and I would like to name it based on the date. (results-11-28-2018)
Thanks

Hi Prankur,
I am new to UiPath and I tried to define the dynamic file name in a variable but it’s not working for me.
Can you give me more details in how I can define the variable?
Thank you,
Ahmed

What variables did you try? and what message is it giving you?

I tried a string variable and in the default box I typed in “filename”+DateTime.Now.ToString+“.xlsx”
I didn’t get an error message it just kept overriding the same file.
I am not sure if I am doing it the right way.
Thanks

do you have a copy of your xaml file?

Main.xaml (9.3 KB)
Thanks

Hi @alotfy

Try this. Hope it helps.

Main (4).xaml (8.4 KB)

2 Likes

@alotfy, ShilpiJ’s workflow will probably work for you, but I think we can leave the time out of the filename and only put the date like so: “results”+Now.ToString(“yyyyMMdd”)+“.xlsx”
Another thing I’d like to mention is that it might look to you as if your file is still overwriting the previous file even though you run this workflow. The reason is that today’s date doesn’t change after you run it, but don’t worry because ‘Now’ will change tomorrow. If you want to double check if it really works, you can run it again tomorrow. If you can’t wait until tomorrow, you can try “results”+Now.AddDays(1).ToString(“yyyyMMdd”)+“.xlsx” the next time you run and that will give you tomorrow’s date.

2 Likes

Thank you ShilpiJ!! it worked. I really appreciate your help.

3 Likes

When i run ShilpiJ’s workflow it worked but i got a strange number at the end of the file name (results11292018 102344.xlsx) and every time i run it creates a new file which is good. When i tried “results”+Now.ToString(“yyyyMMdd”)+“.xlsx” i didn’t get that strange number at the end of the file name but as you said it overwrites the file if i run it on the same day more than once, which is okay. Thank you for your help pathLessTaken!

@alotfy That number is current date & time :slight_smile:

1 Like

Ohh i knew about the date but didn’t know about the time! that makes sense! thanks again!