Docs API Reference

Context.document property

Gets an object that represents the document the add-in in interacting with.

Hosts: Access, Excel, PowerPoint, Project, Word
Last changed in 1.1
var _document = Office.context.document;

Return Value

A Document object.

Remarks

Your add-in can use the document property to access API for interacting with content in documents, workbooks, presentations, projects, and databases (in Access web applications).

Example

// Extension initialization code.
var _document;

// The initialize function is required for all add-ins.
Office.initialize = function () {
    // Checks for the DOM to load using the jQuery ready function.
    $(document).ready(function () {
    // After the DOM is loaded, code specific to the add-in can run.
    // Initialize instance variables to access API objects.
    _document = Office.context.document;
    });
}

Support details

A capital Y in the following matrix indicates that this property is supported in the corresponding Office host application. An empty cell indicates that the Office host application doesn't support this property.

For more information about Office host application and server requirements, see Requirements for running Office Add-ins.

Office for Windows desktop Office Online (in browser) Office for iPad
Access Y
Excel Y Y Y
PowerPoint Y Y Y
Project Y
Word Y Y Y
Minimum permission level Restricted
Add-in types Content, task pane
Library Office.js
Namespace Office

Support history

Version Changes
1.1 Added support for Excel, PowerPoint, and Word in Office for iPad.
1.1 Added support for Office.context.document to access the database in content add-ins for Access.
1.0 Introduced