"Excel Application Scope: Failed opening the Excel file … Possible reasons: the file is corrupt, the file is already used by another process or you don’t have permissions to open the file. "
But I need to use Excel Application Scope: because I use VBA editor, using hot keys copy paste VBA code from notepad and execute it using F5.
First thing is you should be working in modern so you’d be using the Excel Process Scope and Use Excel File.
But have you addressed what the error says? Is the file corrupt? Does someone else or some program have it open? Do you have permissions to open it?
Try going into Task Manager and killing all Excel processes. Sometimes Excel stays hanging in the background and has hold of the file. This even happens when UiPath has stopped incorrectly while reading a file.
Try creating a brand new Excel file yourself with a column and row or two, and see if it reads properly.
Thank you.
This error is happening because I am in a remote machine with 0365.
Disabled OneDrive thinking sync causing issues. But still environment is the issue.
For a similar error in Excel Application Scope which is not running a macro, I replaced with Workbook scope. It worked fine. But for this, I need to run macro from UI.
If you use the modern activities (Excel Process Scope and Use Excel File) there are options in them for what to do if the file is already open, how to handle macros, etc.
Also, when you say run a macro from the UI do you mean clicking and typing in Excel to run a macro after the file is open? If that’s what you mean, Excel Application Scope (or Excel Process Scope) is not the way to open the file. For UI automation in Excel (which isn’t normally done) you’d have to use the Use Application/Browser activity.
The point is you can run macros with Invoke VBA if you Use the file with the correct settings. If that’s against your rules, then I’m not sure what you expect. Why would your security rules prevent you from using the Invoke VBA activity but not prevent you from using another activity. It’s still an activity doing the same thing…
Looks like the issue is because you are trying to access the file from your one drive location…
Instead try to copy the file to a local location where there is no one drive or a sync and then try to perform your actions and once done try to move the file to its original location.This should solve the issue