Read Range from Excel witout Excel Application Scope

Hi @all,

I try to find a solution for the following:
My Bot opens a browser-app and at the end he downloads an Excelfile. So the Excelfile is on the screen now and i need to read data from it. I have no Excel Application Scope! The name of the Excelfile changes every time so I cant use the path for using Excel Aplpication Scope.

Is there a way to getting data from Excel without using Excel Apllication Scope?

Thanks - Rainer

Hi @rainer.buschke ,

Does the file get downloaded to your local machine and into your Downloads Directory?

Kind Regards,
Ashwin A.K

@ashwin.ashok yes, it will be downloaded but every time under another name. so I cant identify the file correctly.

Hi @rainer.buschke ,

Just wanted to Know whether Wait For Download Activity is being used in this case, Or if possible to Shift to Wait For Download Activity, since it Provides the Path of the Downloaded File, Once it is Downloaded.

You could then Kill the Excel Process if the Excel is being opened, then use Excel or Workbook Activities to read the Downloaded file.

More Info on the Activity :

@supermanPunch Thanks for the hint! I will try this out. Just wondering if there is a way to getting data from the openend Excelfile directly…

Hi @rainer.buschke ,

We can retrieve the file with this snippet of code →

Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Downloads","*.xlsx").OrderByDescending(Function(w) New FileInfo(w)).First()

image

Basically it will retrieve the latest Excel File Path in the Download Directory.

Another approach, would be to use a Get Attribute to retrieve the href component and then use the HTTPS Request Activity to download the File(Resource Path).

This approach is much more robust, and I’ve used it in several of my projects.

As for getting the file from an opened Excel File, you will have to go for UI interaction, which is not recommended.

Kind Regards,
Ashwin A.K

Thanks Ashwin! If I understand it right, there is no activity getting data from Excel if we dont open the file ourthelves.

So I have to follow the way picking up the downloaded file. But the Bot will run on a terminal server where I cant be sure that admins will switch the download directory. At first I will give Wait For Download a change…

Hi @rainer.buschke ,

Yep, that is the approach you have to assume, and there are many ways to go about developing a solution.

The more approaches you explore, then better RPA Developer you become.

Kind Regards,
Ashwin A.K

@ashwin.ashok and @supermanPunch
Thanks for your quick help. I found a solution via stroring the file in the download directory and than open it with Excel Application Scope for getting the data.

Regards Rainer

1 Like

Hi @rainer.buschke ,

Great!
Glad that you were able to find a solution on your own.

Kind Regards,
Ashwin A.K