web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Close Excel Error: Sys...
Power Automate
Unanswered

Close Excel Error: System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.

(0) ShareShare
ReportReport
Posted on by 34

Hello all,

 

I am getting an error when using the "Close Excel" action in Power Automate Desktop. I am using it to close and save my Excel file in Power Automate Desktop. However, I am getting this error I couldn't find any more details on the common troubleshooting errors page here. https://learn.microsoft.com/en-us/troubleshoot/power-platform/power-automate/desktop-flows/troubleshoot-excel-errors

 

From the error message (listed below), I couldn't find anything about what "COM object that has been separated from its underlying RCW cannot be used" meant. Would someone be able to help me out? I wasn't sure if this was a OneDrive issue (as the file is being saved to OneDrive) or something else that could be fixed up.

 

Here is the full error message:

 

Problem while executing action 'CloseAndSaveAs'. Failed to close Excel instance. 
 
Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionException: Failed to close Excel instance. ---> System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
 at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
 at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
 at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
 at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.ExcelActions.InvokeMethod(Object o, String methodName, Object[] methodArgs)
 at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.ExcelActions.CloseExcel(Variant excelInstance, Variant documentPath, Int32 save, Int32 saveAsFormat, String xmlMapName)
 --- End of inner exception stack trace ---
 at Microsoft.Flow.RPA.Desktop.Modules.Excel.Actions.CloseExcel.Execute(ActionContext context)
 at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)

 

 

I have the same question (0)
  • Gidi Profile Picture
    601 on at

    Hi ahleonar,

    I would also assume that’s a problem with OneDrive Synch too. 

    I’ve asked Copilot and received the following tip (e.g. use Retry handling in the Excel action):

     

    This error message is usually encountered when the COM object is not properly released or disposed of.

    I found a thread on the UiPath Community Forum 1 that discusses a similar issue. One of the users suggests that the error message could be resolved by upgrading the UiPath.Excel.Activities package to the latest version. Another user suggests that the error message could be resolved by using a retry for each Excel Application Scope activity.

    … you can try the following steps:

    • Ensure that the Excel application is closed properly after the Excel Application Scope activity is completed.
    • Ensure that the Excel application is not running in the background.
    • Ensure that the Excel application is not being used by another process.

    If the issue persists, I recommend that you reach out to the Power Automate Desktop support team for further assistance.

    I hope this helps!

     

     

  • AL-15081948-0 Profile Picture
    34 on at

    @Gidi Thanks for the response, I do have a retry policy setup and no luck, unfortunately. 

     

    This might be something I need to reach out to the support team for. Appreciate the help though!

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    It is very likely related to the auto-sync that OneDrive does. It always causes problems when you want to write to an Excel file on OneDrive via the normal Excel actions (as opposed to Excel online).

     

    The best solution for this is to copy the file locally before launching it, then doing the manipulations you need, and then pushing it back to OneDrive.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard