Fixing “Automation error: The object invoked has disconnected from its clients.”

The error “Automation error: The object invoked has disconnected from its clients” (runtime error code -2147417848 or 0x80010108 / RPC_E_DISCONNECTED) occurs when Excel VBA attempts to read from or write to an out-of-process COM object, external application, or internal worksheet element that has crashed, closed, or dropped its Remote Procedure Call (RPC) channel.

Quick Answer

This failure means the target process (such as Word, Outlook, an external API, or a secondary Excel thread) terminated unexpectedly while your code was still referencing it. Fix the immediate issue by disabling events before executing actions that trigger background updates (Application.EnableEvents = False), removing DoEvents calls within intensive loops, and ensuring you do not call properties on an external application after executing its .Quit or .Close method.


Why the Remote Procedure Call (RPC) Disconnects

When VBA interacts with an external component (such as Word via CreateObject("Word.Application")) or performs high-overhead tasks across workbook interfaces, communication travels across a COM interface using an RPC proxy.

If the host application closes, encounters an unhandled internal exception, or gets terminated by Windows memory management, the server side of the connection vanishes. When VBA makes its next call to that object pointer, the stub has no listening process to talk to, generating the disconnected client error.

VBA Runtime (Client)                      External App / COM Server
         │                                            │
         ├─── RPC Request: Get Data ─────────────────►│
         │◄── Data Returned ──────────────────────────┤
         │                                            │
         │    [Action triggers crash or .Quit] ──────►X  (Terminates)
         │
         ├─── Next Request: Set Range ───────────────►X  (No listener)
         │
         ▼
Runtime Error 0x80010108:
"The object invoked has disconnected from its clients"

The underlying causes fall into three main categories:

  1. Premature process destruction: Code attempts to use an object reference after the parent application has quit or closed.
  2. Re-entrant execution cycles: DoEvents statements allow user clicks or background calculations to interrupt an active COM transaction.
  3. Internal application state crashes: Heavy operations, memory leaks, or unstable third-party add-ins crash the host process during execution.

Step 1: Diagnose Object Life-Cycle Failures

The most common mistake in automation routines is calling an object’s member after destroying the parent instance or letting an object reference fall out of scope.

Consider this flawed automation pattern:

Dim wdApp As Object
Dim wdDoc As Object

Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Open("C:\Reports\Summary.docx")

' ... operations on document ...

wdDoc.Close False
wdApp.Quit

' BUG: Calling a method or property after quitting the host application
wdApp.Visible = False  '<-- Triggers "Disconnected from its clients"
Set wdApp = Nothing

The Fix

Structure your teardown sequences in strict reverse order of instantiation, and do not reference child objects (documents, sheets, paragraphs) after the parent container has been instructed to terminate:

On Error GoTo CleanExit

' Process data
wdDoc.Save
wdDoc.Close False
Set wdDoc = Nothing

wdApp.Quit
Set wdApp = Nothing
Exit Sub

CleanExit:
    If Not wdDoc Is Nothing Then Set wdDoc = Nothing
    If Not wdApp Is Nothing Then
        wdApp.Quit
        Set wdApp = Nothing
    End If

To avoid leaving lingering zombie processes that lock system resources, see Excel Crashing on Close: How to properly clear Object variables from memory..


Step 2: Remove DoEvents and Suppress Application Re-entrancy

Using DoEvents inside large loops to keep the user interface responsive is a frequent trigger of RPC disconnects. When DoEvents yields execution to the Windows message pump, the user can click on the worksheet, trigger an event handler, or switch active workbooks while an automation step is waiting for a return packet.

' RISKY: Yielding control during COM transactions
For i = 1 To 10000
    Set xlCell = ws.Cells(i, 1)
    xlCell.Value = ProcessData(i)
    DoEvents ' <-- If user clicks the grid, COM RPC proxy breaks
Next i

The Fix

  1. Remove DoEvents from loops that interact with external COM servers or perform rapid cell writes.
  2. Turn off screen painting and event processing before the loop starts:
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Interactive = False ' Prevents user mouse/keyboard input during execution

On Error GoTo ErrHandler

' Run your critical processing here

ErrHandler:
Application.Interactive = True
Application.EnableEvents = True
Application.ScreenUpdating = True

If your application suffers from lockups while handling interface states, review Handling “ScreenUpdating” and “Calculation” mode freezes. and Events Debugging: Why EnableEvents = False is necessary to prevent infinite loops.. If a script crash leaves your Excel environment in an unresponsive state, you can restore standard controls using Building a “Reset” macro to fix Excel settings after a crash (Calculation, ScreenUpdating)..


Step 3: Eliminate Explicit Shapes and ActiveSheet Coupling

When automating Excel from an external language (such as PowerShell, VBScript, Python, or MS Access) or manipulating Excel shapes and pivot caches in background threads, referencing unqualified global objects (ActiveSheet, Selection, ActiveWorkbook) will cause RPC dropouts if Excel switches focus.

Faulty Global Reference

' Fails if Excel loses active window focus during processing
ActiveSheet.Shapes("Chart 1").Copy
ActiveSheet.Paste

Resilient Explicit Reference

Dim wbTarget As Workbook
Dim wsTarget As Worksheet

Set wbTarget = Application.Workbooks("MonthlyReport.xlsx")
Set wsTarget = wbTarget.Worksheets("Data")

' Fully qualified hierarchy prevents RPC dispatch detachment
wsTarget.Cells(1, 1).Value = "Updated"

Step 4: Rule Out Third-Party Add-In Collisions

If the error appears intermittently on standard VBA statements (such as Set ws = Worksheets("Sheet1") or Range.Copy), an installed COM add-in is likely crashing in the background and taking down the shared process runtime.

To isolate add-in interference:

  1. Open Excel in Safe Mode by holding down Ctrl while launching the application, or by typing excel /safe in the Windows Run prompt (Win + R).
  2. Run your macro workflow.
  3. If the error disappears, re-enable your add-ins one by one under File > Options > Add-ins > Manage: COM Add-ins to find the failing extension.

For detailed procedures on testing third-party tools, read COM Add-in Conflicts: How to identify which add-in is crashing Excel..