Office.Addin interface

Represents add-in level functionality for operating or configuring various aspects of the add-in.

Remarks

Requirement set: SharedRuntime 1.1

Properties

beforeDocumentCloseNotification

Represents a modal notification dialog that can appear when the user attempts to close a document. The document won't close until the user responds. This API is only supported in Excel.

Methods

getStartupBehavior()

Gets the current startup behavior for the add-in.

hide()

Hides the task pane.

onVisibilityModeChanged(handler)

Adds a handler for the onVisibilityModeChanged event.

setStartupBehavior(behavior)

Sets the startup behavior for the add-in for when the document is opened next time.

showAsTaskpane()

Shows the task pane associated with the add-in.

Property Details

beforeDocumentCloseNotification

Represents a modal notification dialog that can appear when the user attempts to close a document. The document won't close until the user responds. This API is only supported in Excel.

beforeDocumentCloseNotification: BeforeDocumentCloseNotification;

Property Value

Remarks

Requirement set: SharedRuntime 1.2

Method Details

getStartupBehavior()

Gets the current startup behavior for the add-in.

getStartupBehavior(): Promise<Office.StartupBehavior>;

Returns

Remarks

Requirement set: SharedRuntime 1.1

hide()

Hides the task pane.

hide(): Promise<void>;

Returns

Promise<void>

A promise that is resolved when the UI is hidden.

Remarks

Requirement set: SharedRuntime 1.1

onVisibilityModeChanged(handler)

Adds a handler for the onVisibilityModeChanged event.

onVisibilityModeChanged(
            handler: (message: VisibilityModeChangedMessage) => void,
        ): Promise<() => Promise<void>>;

Parameters

handler

(message: Office.VisibilityModeChangedMessage) => void

The handler function that is called when the event is emitted. This function takes in a message for the receiving component.

Returns

Promise<() => Promise<void>>

A promise that resolves to a function when the handler is added. Calling it removes the handler.

Remarks

Requirement set: SharedRuntime 1.1

Examples

Office.onReady(() => {
    Office.addin.onVisibilityModeChanged((args) => {
        if (args.visibilityMode === Office.VisibilityMode.taskpane) {
            // Do something when the task pane is visible.
        }
    });

    // Other startup tasks.
});

setStartupBehavior(behavior)

Sets the startup behavior for the add-in for when the document is opened next time.

setStartupBehavior(behavior: Office.StartupBehavior): Promise<void>;

Parameters

behavior
Office.StartupBehavior

Specifies startup behavior of the add-in.

Returns

Promise<void>

Remarks

Requirement set: SharedRuntime 1.1

Examples

// Configure your add-in to load and start running when the document is opened.
Office.addin.setStartupBehavior(Office.StartupBehavior.load);

showAsTaskpane()

Shows the task pane associated with the add-in.

showAsTaskpane(): Promise<void>;

Returns

Promise<void>

A promise that is resolved when the UI is shown.

Remarks

Requirement set: SharedRuntime 1.1