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 / Power Automate Desktop...
Power Automate
Unanswered

Power Automate Desktop: Excel Instance Gets Disconnected in Second Loop Iteration

(0) ShareShare
ReportReport
Posted on by 2

Hello everyone,

I’m currently working on an automation in Power Automate Desktop, where I need to read data from an Excel file row by row and write values back into the same or another Excel sheet. I’ve encountered a frustrating issue where my flow works fine in the first loop iteration, but when it reaches the second iteration, I get an error that disconnects the Excel instance.

Here’s the situation:

  • Flow Setup:

    • I open an Excel file and store the instance in a variable (let's call it %ExcelInstance%).
    • I use a loop to iterate through a data table extracted from the Excel file. For each row, I write some data back to the Excel sheet. After that I export the sheet as PDF file.
    • I’m using the Excel instance stored in %ExcelInstance% in all actions related to Excel (writing data, referencing the sheet, etc.).
  • The Problem:

    • The first iteration of the loop works perfectly—data is extracted, processed, written to the Excel sheet and exported to PDF.
    • However, on the second loop iteration, I get an error that says the Excel instance has been disconnected:

      "The object invoked has disconnected from its clients" (HRESULT 0x80010108 - RPC_E_DISCONNECTED).

    • This error occurs when the "Write to Excel" action tries to use the existing Excel instance.
  • What I’ve Tried:

    1. Ensuring the instance is referenced correctly: I’ve made sure the same %ExcelInstance% variable is used consistently throughout the loop.
    2. Setting the active Excel instance: I’ve tried adding a "Set Active Excel Instance" action before the write operation in the loop to ensure the correct instance is used.
    3. Adding delays: I’ve added a pause between actions to give Excel some time to complete operations before moving to the next step.
    4. Not closing Excel prematurely: I made sure that Excel isn’t being closed at any point during the loop.
  • Questions:

    1. Has anyone encountered this type of disconnection error before? What could be causing Excel to lose its connection to Power Automate Desktop during the second loop iteration?
    2. Could there be an issue with Excel itself, such as a background process or dialog that’s interfering with the automation?
    3. Are there best practices for managing Excel instances within loops in Power Automate Desktop that might help avoid this problem?

Any advice or guidance would be greatly appreciated! I’ve been stuck on this issue for a while and would love some help from the community. If you need any additional information or specifics about my setup, I’m happy to provide that as well.

Thank you so much in advance!

Best regards,

I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at
    Try addind "Attach to running Excel" -action if the second loop fails in the first "write to Excel worksheet" -action. 

    So on the action that usually fails since it cant find the ExcelInstance add OnError and set it to "Go to next action" and from New rule set variable "ExcelNotFound" to %True%



    Then add condition that if "ExcelNotFound" is True then use Attach to running Excel -action. Then se the ExcelNotFound to False so it doesn't do that condition on every loop if its not needed.


    Or you could try to add the Attach to running Excel simply before the second loop. Also I would troubleshoot by disabling the pdf export and see if that is the part that makes ExcelInstance to get lost.
  • Suggested answer
    AS-26092108-0 Profile Picture
    2 on at
    Hello again and thank you @eetuRobo for your answer!
    In the meantime I found the issue and it was simpler that I thought.
     
    It was the Adobe PDF Creator. After I switched to another way of creating the PDFs out of the Excel sheet, everything went fine.
     
    Thank you!
     
    Br
    Alex

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 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard