When You See This Error
You're automating an Office app—Excel, Outlook, Word—or calling a COM object from a script, and out of nowhere you get DISP_E_BADPARAMCOUNT (0x8002000E). The message says "Invalid number of parameters." It hits right after you add a new argument to a function call or when you migrate a legacy script from one machine to another. I've seen it most often in VBScript, PowerShell (with COM objects), and legacy VB6 apps trying to talk to newer Office versions.
The trigger is almost always a mismatch between what the calling code passes and what the COM method expects. For example, you think Worksheet.Cells.Item takes two arguments (row, column), but actually it accepts one, two, or three depending on context. You write Cells.Item(1), and boom—0x8002000E because the method got one argument when it needed two.
Root Cause
COM interfaces are strict about argument counts. Unlike some APIs that ignore extra parameters or fill in missing ones, COM methods have a fixed signature. When you call a method with fewer or more arguments than defined, the dispatch layer returns DISP_E_BADPARAMCOUNT. It's a runtime check that doesn't care about optional parameters—if you omit one that's actually optional, it still might throw if the method's IDL says it's required.
Common culprits:
- Overloaded methods where you're using the wrong overload.
- Passing a parameter array as a single object instead of expanding it (PowerShell gotcha).
- Using late binding (e.g.,
CreateObject) when the object expects early-bound calls. - Upgraded Office or a COM component that changed its method signatures (e.g., added a mandatory parameter).
Don't waste time chasing registry tweaks or reinstalling Office. The error is in your code or the calling convention.
How to Fix It
Follow these steps. The solution is rarely just one thing—it's methodical debugging.
- Reproduce and isolate. Write the smallest script that triggers the error. Strip away everything else. If it still fails, you've got a minimal test case.
- Check the method's documentation. Look up the exact signature. For Office objects, Microsoft's VBA reference shows parameter lists. For example, in Excel's
Range.Find, the parameter order is(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, ...). If you're passing only one argument when it expects at least two, you'll get this error. - Count your arguments manually. In your script, add a comment listing each argument. Verify against the signature.
- Beware of optional parameters. Some COM methods allow you to skip optional params, but others require you to pass
Type.MissingorNothingfor each one you skip. In C#, it'sType.Missing; in VBScript, an empty string often works, but not always. - Fix PowerShell array calls. If you're using PowerShell, a classic mistake is passing an array as a single argument. You need the splatting operator (
@) to expand it. For example,Invoke-WebRequest -Uri $url -Headers $headers—if you doInvoke-WebRequest $url @headerswithout the splat, it fails. - Switch to late binding if you're using early binding. Sometimes the type library on your system is stale. Use
CreateObjectinstead of a project reference to bypass the cached type library. - Update your Office or component. If the method signature changed in a newer version, install the service pack or patch. Check the vendor's release notes.
Still failing?
If you've done all that and the error persists, check these:
- Are you using the correct object type? Example:
Application.Runin Excel expects at least a macro name, but if you pass a sheet object instead, it might misinterpret the argument count. - Is the COM server 32-bit vs 64-bit? A 64-bit script calling a 32-only COM component can throw weird errors. Ensure your scripting host matches the component's bitness.
- Look at the call stack. If you're using a debugger or tracing, see which method actually threw. Sometimes the error comes from a nested call, not your top-level function.
- Try a different binding method. For example, in VBA, use
Application.Runwith a parameter array, but in PowerShell, you might need to use[System.Type]::Missingfor every optional param.
Last resort: run a COM trace using Process Monitor to see the exact IMessageFilter calls. But honestly, in 14 years, I've never needed that for this error—it's always a code fix. Don't overthink it.
If you're pulling your hair out over a specific Office method, post your code snippet on a forum. Include the line that fails and the exact version of Office. People will spot the missing argument in minutes.