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:
- A missing or broken reference in your project
- An object that's gone bad — usually set to Nothing at the wrong time
- 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
- Open your VB6 project, or in VBA (Excel/Access/Word) press
Alt+F11to open the editor. - Go to the menu: Tools → References.
- 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. - Uncheck that broken reference. Don't worry — your code will still compile if you use late binding (more on that later).
- 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.
- Click OK. Then go to Debug → Compile 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
- Search your code for
Set obj = Nothing. Comment out every occurrence. - 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.
- 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
- 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.
- If you can, install the same version on the target machine. That's the clean fix.
- 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
| Cause | Symptom | Fix |
|---|---|---|
| Missing/broken reference | "MISSING" in References dialog, compile-time error | Uncheck missing ref, re-add correct version, or switch to late binding |
| Object set to Nothing too early | Error happens after Set obj = Nothing | Remove early Nothing assignments, free object only at end |
| Version mismatch | Error on a specific method/property call | Compile 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.