Skip to main content
Access via:io.word

Word API.

Properties (2)

Property Type Default Required Description
addinStatus⚓︎ boolean x

Flag indicating the status of the Word Adapter. If true, the Word Adapter is available and you can use the Word API.

all⚓︎ Document[] x

Retrieves all documents opened by the current app in Word.

3 Methods

onAddinStatusChanged()⚓︎

(callback: (args: { connected: boolean }) => void) => UnsubscribeFunction

Notifies when the Word Adapter status has changed.

Parameters (1)

Name Type Required Description
callback⚓︎ (args: { connected: boolean }) => void

Callback function for handling the event. Receives as an argument an object with a connected Boolean property indicating the status of the Word Adapter. The callback will be invoked immediately with the current status of the Word Adapter on subscribe.

Example

office.word.onAddinStatusChanged(({ connected }) => {
    if (connected) {
        console.log("The Word Adapter is available.");
    } else {
        console.log("The Word Adapter is unavailable.");
    }
});

openDocument()⚓︎

(config: OpenDocumentConfig) => Promise<Document>

Opens a document in Word.

Parameters (1)

Name Type Required Description
config⚓︎ OpenDocumentConfig

Configuration for opening the Word document.

Example

const options = {
    name: "MyFirstDocument",
    data: "<html><h1>Hello world!</h1></html>",
    isDocx: false,
};

const myDoc = await office.word.openDocument(options);
console.log(myDoc);

ready()⚓︎

() => Promise<object>

Resolves with the Word API object.