Saving an xls file as xlsx

Hi everyone, I’m going to explain what my problem is and hope that someone can help me.

I basically have a project that downloads two xls files from different ERPs that have varying names by date and hour that I download it. What I want is, as soon as I close one ERP, I want to convert that most recent xls file as a xlsx file with the name just like MonthYear (example: March24) and save it on another folder, can you guys help me out?

1 Like

There are many options for this, but it really depends on details not included in your question.

If what you are downloading requires clicking a button and waiting for the download to go to your downloads folder, then you can use the activity “Wait for Download” which monitors your download folder for new files and outputs the downloaded file name.

From there you can use the move file activity to take the file and move/rename it; it takes 2 arguments, From and Destination. In from argument put the path of your downloaded file in the “From” and path of where you want the file saved with the new file in the To.

To generate the name you can use now.tostring(“MMMM”) + now.tostring(“yy”)

I believe if you just change the file extension when changing the name to “.xlsx” then it should change the file, so as part of your new file name you can just add “.xlsx” to the end in the “To” portion.

1 Like

I’m curious why you want to change it from .xls to .xlsx - there is no difference for an automation. You can read both.

Anyway, the simplest way is just to Read Range into a datatable then Write Range to a new file.

1 Like

I do click a button and wait for the download to go to downloads folder (specifically desktop, but it doesn’t matter), But I’m having trouble as how does the “Wait for Download” actually work, do I have to put all activities that lead to the download inside it?

As move file, I know that is generally in english, but can I save it in any other language (I’m Brazilian, so I would hope that instead of March24 it went Março24)

Unfortunately, just changing the file extension doesn’t work :frowning:

1 Like

Hey! It’s because I want Power BI to read it, and it can’t read xls (97-2003) files, I will try read range/write range!! But can it detect the most recent file?

1 Like

Just use the delete file activity after you have saved it.

1 Like

You just need your click activity inside the activity. You may want to add tmp,crdownload,dwn in the ignore these temporary file extensions argument section. For languages, it uses whatever your system environment language is set to.

1 Like

I’m not sure what you mean by detect the most recent file. Do you mean you want to process only the latest file from the folder?

That you would do with an expression. See this page for info on how to get a list of files and filter them…

1 Like

Basically I want my project to download each xls (97-2003) file on different ERPs, and save each as an xlsx file. I can’t use any activity that checks file names since they change (example: Sales_03_15_2024_08_17_45) and each time I download it, it changes (the other ERP also have the same naming problem, but it’s other data that I download it there).

So, what I need is that UI Path convert that newest downloaded xls file to xlsx and save it in another folder before opening the second ERP and do the same process.

Hope that I made myself clear this time, sorry it’s been a while since I chatted in english

The Wait for Download activity will wait for a new file to be created in the folder and return its name (and other information). Then you can Read Range that file, then Write Range to .xlsx in the new folder.

Can you show me exactly how does it work? I’m having a little bit of trouble, should I just put the read range inside? but it says that it’s only valid inside an excel application scope

I suggest doing the free training at - it will teach you these basic things. There is even one specific to Excel.

You don’t put the Read Range inside the Wait for Download. You put an activity (like a click) that initiates the download in there. Then after the Wait for Download you use your Excel activities to read the file based on the output of the Wait for Download.

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