Edit

Office.ContextInformation interface

Provides information about the environment in which the add-in is running.

Remarks

Important: In Outlook, this object is available starting with Mailbox requirement set 1.5. For all Mailbox requirement sets, you can use the Office.context.mailbox.diagnostics property to get similar information.

Used by

Properties

host

Gets the Office application in which the add-in is running.

platform

Gets the platform on which the add-in is running.

version

Gets the version of Office on which the add-in is running.

Property Details

host

Gets the Office application in which the add-in is running.

host: Office.HostType;

Property Value

Examples

const contextInfo = Office.context.diagnostics;
console.log("Office application: " + contextInfo.host);

platform

Gets the platform on which the add-in is running.

platform: Office.PlatformType;

Property Value

Remarks

Important: In Outlook, OfficeOnline is returned if an add-is is running in Outlook on the web or in new Outlook on Windows.

Examples

const contextInfo = Office.context.diagnostics;
console.log("Platform: " + contextInfo.platform);

version

Gets the version of Office on which the add-in is running.

version: string;

Property Value

string

Examples

// Checks whether the Office on Windows version meets a feature's minimum requirements.
const clientVersion = Office.context.diagnostics.version;

// In Office on Windows, the version property is in the format "16.0.<build>.<revision>".
// In this example, Version 2603 (Build 19822.20000) is the minimum version required for the feature.
// 19822 is the build number and 20000 is the revision number.
const minBuildRevision = "19822.20000";

const [, , clientBuild, clientRevision] = clientVersion.split(".");
const [minBuild, minRevision] = minBuildRevision.split(".");

const clientBuildNumber = parseInt(clientBuild, 10);
const clientRevisionNumber = parseInt(clientRevision, 10);
const minBuildNumber = parseInt(minBuild, 10);
const minRevisionNumber = parseInt(minRevision, 10);

if (
    clientBuildNumber > minBuildNumber ||
    (clientBuildNumber === minBuildNumber && clientRevisionNumber >= minRevisionNumber)
) {
    console.log("Office version meets the minimum requirements.");
    // Implement the feature-specific actions here.
} else {
    console.log("Office version doesn't meet the minimum requirements.");
}