0X80020009

DISP_E_EXCEPTION (0X80020009) in VB6/COM: Quick Fixes

This error means a COM component threw an exception. Usually from a missing reference, bad object, or version mismatch. Here's how to fix it step by step.

What is 0X80020009?

This error shows up when a COM component — like an ActiveX DLL, OCX control, or an Office object — throws an exception that VB6 or VBA can't handle on its own. The full message usually says something like "Exception occurred" and then gives you a vague description from the component itself. I've seen this a hundred times in old VB6 apps and Excel macros that talk to Outlook, Word, or some third-party library.

The real problem is almost always one of three things:

  1. A missing or broken reference in your project
  2. An object that's gone bad — usually set to Nothing at the wrong time
  3. A version mismatch between your code and the component you're calling

We'll start with the most common fix, then move down the list. Try them in order.

Cause 1: Missing or broken reference

This is the number one cause. Your project has a reference to a COM library — say, "Microsoft Outlook 16.0 Object Library" — but the file is missing, corrupted, or the version changed. VB6 or VBA loads the reference at compile time, and if it can't find the right file at runtime, you get 0X80020009.

How to check and fix references

  1. Open your VB6 project, or in VBA (Excel/Access/Word) press Alt+F11 to open the editor.
  2. Go to the menu: ToolsReferences.
  3. Look for any reference that says "MISSING" at the start. Those ones have a broken path. You'll see something like MISSING: Microsoft Outlook 15.0 Object Library.
  4. Uncheck that broken reference. Don't worry — your code will still compile if you use late binding (more on that later).
  5. Now find the correct version. For Office components, you want the library that matches your installed Office version. For example, if you have Office 365, it's usually "Microsoft Outlook 16.0 Object Library". Check the box next to it.
  6. Click OK. Then go to DebugCompile VBA Project (or just run the code).

What you should see: After you uncheck the missing reference, the red X on that line disappears. After you add the correct reference, Intellisense works again. The error should stop.

If you can't find the right reference

Sometimes the library you need isn't installed. For example, if you wrote code against Outlook 2010 but the user has Outlook 2019, the 2010 library file might not be there. Your options:

  • Install the older version of Office (not practical).
  • Switch to late binding — see Cause 2 below.

Cause 2: Object variable is set to Nothing or released too early

This one's sneaky. You create an object — Set obj = CreateObject("Outlook.Application") — then at some point you set it to Nothing, or it goes out of scope, and later you try to call a method on it. COM throws 0X80020009 because the object doesn't exist anymore.

I see this a lot in loops where people set Set obj = Nothing inside the loop to free memory, but then try to use obj after the loop. Bad idea.

How to fix it

  1. Search your code for Set obj = Nothing. Comment out every occurrence.
  2. Run your code again. Does the error go away? If yes, you found the problem. You need to keep the object alive until you're completely done with it.
  3. If you must free memory, do it only at the very end of your procedure, after all uses.

What you should see: The error stops happening at the line where you were calling the object method. If it still happens, move to the next fix.

Use late binding to avoid version issues

Late binding means you don't set a reference at design time. Instead, you use CreateObject and GetObject. This way, your code works with any version of the component. The trade-off: no Intellisense, and slightly slower calls. But for 0X80020009, late binding often saves you.

Example — early binding (causes problems):

Dim olApp As Outlook.Application
Set olApp = New Outlook.Application
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)

Switch to late binding:

Dim olApp As Object
Set olApp = CreateObject("Outlook.Application")
Dim olMail As Object
Set olMail = olApp.CreateItem(0)  ' 0 = olMailItem

Notice I used 0 instead of the constant olMailItem. That's because constants are only available with early binding. You'll need to replace all constants with their numeric values. A quick way: look them up in the Object Browser (F2) before you switch, or search online.

Cause 3: Version mismatch — compiled DLL vs runtime

This happens when you compile a VB6 EXE or DLL that references a COM component, then deploy it to a machine that has a different version of that component. The error 0X80020009 pops up when your code tries to call a method that doesn't exist in the older version, or that changed its parameters.

How to fix it

  1. On the target machine, check what version of the component is installed. For Office, go to the About box in the app. For third-party DLLs, check Add/Remove Programs.
  2. If you can, install the same version on the target machine. That's the clean fix.
  3. If you can't control the target version, you must compile your project on a machine with the lowest version you need to support, or use late binding.

For example, if you compiled against Outlook 2016 (version 16.0), but the user has Outlook 2013 (version 15.0), the MailItem.Send method might still work, but some newer properties won't. Using late binding (Cause 2) lets your code handle this gracefully by checking Is Nothing or using On Error Resume Next around specific calls.

Quick-reference summary table

CauseSymptomFix
Missing/broken reference"MISSING" in References dialog, compile-time errorUncheck missing ref, re-add correct version, or switch to late binding
Object set to Nothing too earlyError happens after Set obj = NothingRemove early Nothing assignments, free object only at end
Version mismatchError on a specific method/property callCompile on lowest version, or use late binding

If none of these work, check your On Error handling. Sometimes the error is caught and re-raised. Comment out any On Error Resume Next temporarily to see the real error line. That's saved me more than once.

Related Errors in Programming & Dev Tools
java.lang.OutOfMemoryError: Java heap space Fix Java OutOfMemoryError: Java heap space 0X000000CF Fix ERROR_RING2_STACK_IN_USE (0X000000CF) on Windows 10/11 0X00000504 Fix ERROR_DEBUGGER_INACTIVE (0X00000504) in VS Code 0X0000030D Desktop Heap Error 0x0000030D: Fix Session Memory Allocation

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.