Export (0) Print
Expand All

Error.code property (JavaScript API for Office v1.1)

JavaScript API for Office v1.1

Gets the numeric code of the error.

Last modified: June 12, 2014

Introduced in Office.js version


Updated in Office.js version


var errCode = asyncResult.error.code;

The error code as a number.

The Error object and its properties are accessed from the AsyncResult object that is returned in the function passed as the callback argument of an asynchronous data operation.

Added support for content apps for Access.

To cause an error to be thrown, select a table or a matrix, and then call the setText function.

function setText() {
    Office.context.document.setSelectedDataAsync("Hello World!",
        function (asyncResult) {
            if (asyncResult.status === "failed")
                var error = asyncResult.error;
            write(error.name + ": " + error.code + " – " + error.message);

// Function that writes to a div with id='message' on the page.
function write(message){
    document.getElementById('message').innerText += message; 

App types

Content apps, Mail apps, Task pane apps

Supported clients

Access app for SharePoint, Excel 2013, Excel 2013 SP1, Excel 2013 RT, Excel Online, Outlook 2013, Outlook 2013 SP1, Outlook 2013 RT, Outlook Web App, OWA for Devices, PowerPoint 2013, PowerPoint 2013 SP1, PowerPoint 2013 RT, Project 2013, Project 2013 SP1, Word 2013, Word 2013 SP1, Word 2013 RT





© 2014 Microsoft