Excel UI freezes after IUIAutomation::AddFocusChangedEventHandler — unsubscribing does not help, only restart fixes it

2026-06-05T09:27:26.9966667+00:00

Hello, I've found a reproducible issue in Microsoft Excel 2010–2024.

Problem: After calling IUIAutomation::AddFocusChangedEventHandler from an external process, Excel starts performing formula recalculations on the UI thread. On large workbooks, the Excel interface becomes unresponsive for several seconds to several minutes. Key issue — unsubscribing does NOT fix it: •RemoveFocusChangedEventHandler — has no effect •RemoveAllEventHandlers — has no effect • Force-killing the process that registered the handler — has no effect Excel continues to freeze as if it doesn't clean up its internal subscription state when the handler is removed. The only workaround is restarting Excel after unsubscription. Steps to reproduce: 1. Open a large workbook in Excel 2010–2024 2. From any external process, call IUIAutomation::AddFocusChangedEventHandler 3. Observe: Excel UI becomes unresponsive during recalculation 4. Call RemoveFocusChangedEventHandler or RemoveAllEventHandlers 5. Observe: freezing persists Expected behavior: After unsubscription, Excel should stop processing focus change events on the UI thread and return to normal performance. Questions: 1. Is this a known issue? 2. Is there a programmatic way to reset Excel's internal UIA event state without restarting? Affected versions: Excel 2010, 2013, 2016, 2019, 2021, 2024

Microsoft 365 and Office | Excel | For business | Other
0 comments No comments

Answer accepted by question author
Michelle-N 20,735 Reputation points Microsoft External Staff Moderator
2026-06-05T11:20:41.68+00:00

I would like to first clarify that this is a user-to-user support forum, and we are not Microsoft support. Moderators here do not have backend access and cannot directly intervene in Microsoft products or perform escalations. We can only provide technical guidance and best-practice recommendations based on reported issues.

Hi @Гудулин Виталий Дмитриевич

Based on your description, I understand that calling IUIAutomation::AddFocusChangedEventHandler from an external process forces Excel (versions 2010–2024) to execute formula recalculations directly on the UI thread. This causes severe unresponsiveness on large workbooks, and crucially, Excel fails to clean up its internal subscription state even after unsubscribing or killing the external calling process. The only current resolution is to restart Excel.

Here are the analysis and guidance based on technical research of Excel's UI architecture:

From a broader technical standpoint, AddFocusChangedEventHandler can act as a system-wide listener that introduces significant inter-process communication (IPC) overhead. Excel's UI thread is notoriously sensitive and heavily intertwined with its drawing and synchronous event-handling loops, especially when automatic recalculation is running on complex workbooks.

However, there is currently no official public documentation, Microsoft KB article, or developer release note classifying this specific unsubscription failure. I Since there is no official API method exposed to force Excel to flush its internal UIA event listener cache without a restart, you can try the following structural workarounds to reduce the performance impact:

Before executing your external UIA tool, programmatically or manually switch Excel to Manual Calculation mode (Application.Calculation = xlCalculationManual). This prevents Excel from triggering heavy recalculation chains on the UI thread every time a focus event fires. If possible, run the target workbook in a completely separate Excel instance so that if a freeze occurs or a restart is required, it does not interrupt the user's main Excel workspace.

To get this behavior analyzed by engineering teams, I highly recommend reporting this behavior directly to Github.
Thank you for your contribution and patience.


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click ""Comment"".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Oldest

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.