DISP_E_NOTACOLLECTION (0X80020011) Quick Fix
This COM error means something expects a collection but got a single item. Almost always a scripting or VBA issue. Fix it by checking your code or repairing Office.
Quick Answer
Pass an array or collection object instead of a single value. For example, Set obj = CreateObject("Scripting.Dictionary") then add items. Or wrap your single item in Array().
Why This Happens
You're dealing with COM automation — likely in VBA, PowerShell, or a scripting language. The error DISP_E_NOTACOLLECTION is Spanish for "you gave me one thing, but I need many." It's a type mismatch within the COM interface. Common triggers: running an old Excel macro that expects a Range object but gets a single cell, or an Access VBA routine that expects a Recordset but gets a single record.
I see this most often when someone copies VBA code from a forum and pastes it without checking the object types. The culprit is almost always a For Each loop where the object isn't a collection, or a function that returns a collection but you're assigning it to a scalar variable.
How to Fix It
- Identify the offending line. The error message usually gives a line number or function name. If not, step through your code line by line in the VBA editor (F8).
- Check the object type. Use
TypeName(variable)in VBA or$variable.GetType()in PowerShell to see what you're actually dealing with. If it saysObjectorStringwhen you expected a collection, that's your problem. - Wrap single items in an array. In VBA:
Set myCollection = Array(singleItem). In PowerShell:$myCollection = @($singleItem). This forces the object to be treated as a collection. - Use a proper collection object. Avoid arrays if you need to add items dynamically. Use
Collectionin VBA (Dim col As New Collection) orArrayListin .NET (New-Object System.Collections.ArrayList). - Repair Office installation. Corrupted COM registrations can cause this. Run
Control Panel > Programs > Microsoft Office > Change > Quick Repair. If that fails, do an Online Repair — it takes longer but fixes more.
Alternative Fixes
- Re-register the COM object. If this is a third-party component, run
regsvr32 yourobj.dllas Administrator. Don't bother with this for standard Office components — it rarely helps. - Update your scripting engine. Old versions of VBScript (pre-5.8) have known collection bugs. Grab the latest from Microsoft's download center.
- Switch to late binding. If you're using early binding (referencing a specific DLL), late binding often sidesteps version mismatches. Replace
Dim app As New Excel.ApplicationwithDim app As Object: Set app = CreateObject("Excel.Application").
Prevention Tip
Always validate your object types before iterating. A simple check like If TypeOf obj Is Collection Then or If IsArray(myVar) Then saves hours of debugging. Also, never assume a COM function returns what you think — read the actual documentation, not a Stack Overflow snippet from 2009.
Pro tip: In VBA, use Debug.Print TypeName(variable) in the Immediate Window to see the type at runtime. That's saved me more times than I can count.Was this solution helpful?