Docs API Reference

ProjectDocument.ViewSelectionChanged event

Occurs when the active view changes in the active project.

Hosts: Project
Available in Requirement set Selection
Added in 1.0


ViewSelectionChanged is an EventType enumeration constant that can be used in the ProjectDocument.addHandlerAsync and ProjectDocument.removeHandlerAsync methods to add or remove a handler for the event.


The following code example adds a handler for the ViewSelectionChanged event. When the active view changes, it gets the name and type of the active view.

The example assumes your add-in 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 () {

            // After the DOM is loaded, add-in-specific code can run.

    // Get the name and type of the active view and display it in the add-in.
    function getActiveView() {
            function (result) {
                if (result.status === Office.AsyncResultStatus.Failed) {
                else {
                    var output = String.format(
                        'View name: {0}<br/>View type: {1}',
                        result.value.viewName, result.value.viewType);

    function onError(error) {
        $('#message').html( + ' ' + error.code + ': ' + error.message);

For an example that shows how to use a ViewSelectionChanged event handler in a Project add-in, see Create your first task pane add-in for Project 2013 by using a text editor.

Support details

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

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)
Project Y
Available in requirement sets
Minimum permission level Restricted
Add-in types Task pane
Library Office.js
Namespace Office

Support history

Version Changes
1.0 Introduced

See also

Other resources

Create your first task pane add-in for Project 2013 by using a text editor EventType enumeration ProjectDocument.addHandlerAsync method ProjectDocument.removeHandlerAsync method ProjectDocument object