Export (0) Print
Expand All

Document.getActiveViewAsync method (JavaScript API for Office v1.1)

Returns the current view of the presentation.

Last modified: June 12, 2014

Introduced in Office.js version

1.1

Available in requirement sets

ActiveView

Office.context.document.getActiveViewAsync([,options], callback);

options

Type: object

Specifies the following optional parameters.

asyncContext

Type: array, boolean, null, number, object, string, or undefined

A user-defined item of any type that is returned in the AsyncResult object without being altered. Optional.

callback

Type: function

A function that is invoked when the callback returns, whose only parameter is of type AsyncResult. Optional.

When the function you passed to the callback parameter executes, it receives an AsyncResult object that you can access from the callback function's only parameter.

In the callback function passed to the getActiveViewAsync method, you can use the properties of the AsyncResult object to return the following information.

Property

Use to...

AsyncResult.value

Return the presentation's current view. The value returned can be either edit or read. "Edit" corresponds to any of the views in which you can edit slides, such as Normal or Outline View. Read corresponds to either Slide Show or Reading View.

AsyncResult.status

Determine the success or failure of the operation.

AsyncResult.error

Access an Error object that provides error information if the operation failed.

AsyncResult.asyncContext

Access your user-defined object or value, if you passed one as the asyncContext parameter.

Can trigger an event when the view changes.

To get the view of the current presentation, you need to write a callback function that returns that value. The following example shows how to:

  • Pass an anonymous callback function that returns the view type to the callback parameter of the getActiveViewAsync method.

  • Display the value on the app's page.

function getFileView() {
    //Get whether the current view is edit or read.
    Office.context.document.getActiveViewAsync(function (asyncResult) {
        if (asyncResult.status == "failed") {
            showMessage("Action failed with error: " + asyncResult.error.message);
        }
        else {
            showMessage(asyncResult.value);
        }
    });
}

App types

Content apps, Task pane apps

Supported clients

PowerPoint 2013, PowerPoint 2013 SP1, PowerPoint 2013 RT, and PowerPoint Online

Library

Office.js

Namespace

Office

Show:
© 2015 Microsoft