ProjectDocument object (JavaScript API for Office)

apps for Office

An abstract class that represents the project document (the active project) with which the app for Office interacts.

Last modified: March 02, 2015

Note Note

The name "apps for Office" is changing to "Office Add-ins". During the transition, the documentation and the UI of some Office host applications and Visual Studio tools might still use the term "apps for Office".

Hosts:

Project

Added in

1.0

See all support details

Office.context.document

Methods

Name

Description

addHandlerAsync method

Asynchronously adds an event handler for an event in a ProjectDocument object.

getProjectFieldAsync method

Asynchronously gets the value of the specified field in the active project.

getResourceFieldAsync method

Asynchronously gets the value of the specified field for the specified resource.

getSelectedDataAsync method

Asynchronously gets the data that is contained in the current selection of one or more cells in the Gantt chart.

getSelectedResourceAsync method

Asynchronously gets the GUID of the selected resource.

getSelectedTaskAsync method

Asynchronously gets the GUID of the selected task.

getSelectedViewAsync method

Asynchronously gets the view type and name of the active view.

getTaskAsync method

Asynchronously gets the task name, the resources that are assigned to the task, and the ID of the task in the synchronized SharePoint task list.

getTaskFieldAsync method

Asynchronously gets the value of the specified field for the specified task.

getWSSUrlAsync method

Asynchronously gets the URL of the synchronized SharePoint task list.

removeHandlerAsync method

Asynchronously removes an event handler for an event in a ProjectDocument object.

Events

Name

Description

ResourceSelectionChanged event

Occurs when the resource selection changes in the active project.

TaskSelectionChanged event

Occurs when the task selection changes in the active project.

ViewSelectionChanged event

Occurs when the active view changes in the active project.

Do not directly call or instantiate the ProjectDocument object in your script.

The following example initializes the app and then gets properties of the Document object that are available in the context of a Project document. A Project document is the opened, active project. To access members of the ProjectDocument object, use the Office.context.document object as shown in the code examples for ProjectDocument methods and events.

The example assumes your app has a reference to the jQuery library and that the following page control is defined in the content div in the page body:

<span id="message"></span>
(function () {
    "use strict";

    // The initialize function must be run each time a new page is loaded.
    Office.initialize = function (reason) {
        $(document).ready(function () {

            // Get information about the document.
            showDocumentProperties();
        });
    };

    // Get the document mode and the URL of the active project.
    function showDocumentProperties() {
        var output = String.format(
            'The document mode is {0}.<br/>The URL of the active project is {1}.',
            Office.context.document.mode,
            Office.context.document.url);
        $('#message').html(output);
    }
})();

A checkmark (√) in the following matrix indicates that this object is supported in the corresponding Office host application. An empty cell indicates that the Office host application doesn't support this object.

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

Office for Windows desktop

Office for Windows RT

Office Online
(in browser)

Project

App types

Task pane

Library

Office.js

Namespace

Office

Version

Changes

1.0

Introduced

Show:
© 2015 Microsoft