Five Common Office API Error Codes and What They Mean

Quick Tips
  • Common Office API error codes refer to the Common API model, not how often these codes appear.
  • There are dozens of Office API error codes you might encounter, with each having a specific fix.
  • Sometimes, fixing is as simple as changing your Microsoft Edge or Windows Firewall settings.

Office Add-ins allow you to extend your standard Microsoft Office solution into something more. Something that can change how you do business or streamline your Office apps to suit your needs. But taking advantage of them means learning how to create Office APIs, and with that comes the potential for errors. Several of them, in fact, which is why we’ve compiled some of the most common Office API error codes and what you should do when you encounter them.

The Five Common API Codes

When we say “common,” we mean error codes that you might come across while working within the Common API model. These aren’t application-specific error codes, as you might encounter when working with the Word JavaScript API, for instance. Here are some you should pay attention to.

Code 1 – Error.code 1000

Error.code 1000 tells you that you have an invalid coercion type somewhere in your code. Excel gives us a good example here. Excel doesn’t support either the HTML or OOXML coercion types, making this code guaranteed if you try to force it. If you don’t already know, type coercion is the process apps follow to convert one object type to another. If there’s a conflict in that conversion, you’re likely to see this error code.

Code 2 – Error.code 2009

This is an easy error code to draw out because it deals with data objects. The larger those objects get, the more chance one of them ballooning beyond the data limits you’ve defined in your Office application. If you see this code, the solution is to shrink down the data object causing the problem.

Code 3 – Error.code 4000

Any coder can tell you that setting names for objects is key to getting a program running properly. If you don’t do that, you’re liable to run into error.code 4000. You get this code when you specify a setting name that doesn’t exist anywhere inside your API code.

Code 4 – Error.code 5002

Permission denied!

That’s the message you’re receiving when you see this error code. It tells you that you – as the solution developer – are attempting to submit an operation using a document that doesn’t give you the appropriate permissions. You’ll see this a lot if you’re using documents in which you restrict editing.

Code 5 – Error.code 9021

Connection errors happen. When they do, you won’t be able to save your item to the server. That’s what error.code 9021 tells you – there’s a connection error somewhere in your setup that you need to fix. For instance, problems with “Online Mode” when using Outlook Desktop can trigger this error.

Quick Fixes for Common Office API Error Codes

We’ve only touched on a handful of the common Office API error codes you might encounter in your development career. Each has individual fixes that involve you figuring out where your code went wrong and what you have to do about it. But there are a couple of quick potential fixes you can try across all of the codes.

Fix 1. Verify Your Firewall Settings

Your firewall might be getting in the way of the application you’re trying to run. Turning it off, or verifying the firewall’s settings so it’s not trying to block the program you’ve created, could give you a quick fix.

Step 1. Type “Windows Security” into the search bar at the bottom of your screen and click the icon with the same name.

The Five Common API Codes 1

Step 2. Select “Firewall & network protection” from the options on the left and scan your various domains to see their firewall settings. Turning off your domain or private networks may get your API code up and running.

The Five Common API Codes 2The Five Common API Codes 2

Step 3. Alternatively, click “Allow an app through firewall” and grant the app you’ve created permission to break through your Windows firewall.

The Five Common API Codes 3The Five Common API Codes 3
The Five Common API Codes 4The Five Common API Codes 4

Fix 2. Turn Off Microsoft Edge Compatibility Mode

If you get any web-related errors concerning the properties you define, Microsoft Edge running in compatibility mode may be the problem. Here’s how to turn it off.

Step 1. Click on the ellipses – the “…” symbol – at the top-right of Edge and select “Settings.”

The Five Common API Codes 5The Five Common API Codes 5

Step 2. Head to the “Default Browser” tab using the navigation bar.

The Five Common API Codes 6The Five Common API Codes 6

Step 3. Select “Don’t Allow” from the drop-down box next to “Allow sites to be reloaded in Internet Explore mode (IE mode).”

The Five Common API Codes 7The Five Common API Codes 7

Thanks for your feedback!

Leave a Reply

Your email address will not be published. Required fields are marked *