OfficeExtension.ClientObject class

An abstract proxy object that represents an object in an Office document. You create proxy objects from the context (or from other proxy objects), add commands to a queue to act on the object, and then synchronize the proxy object state with the document by calling context.sync().

Properties

context

The request context associated with the object

isNullObject

Returns a boolean value for whether the corresponding object is a null object. You must call context.sync() before reading the isNullObject property.

Property Details

context

The request context associated with the object

context: ClientRequestContext;

Property Value

isNullObject

Returns a boolean value for whether the corresponding object is a null object. You must call context.sync() before reading the isNullObject property.

isNullObject: boolean;

Property Value

boolean

Examples

// This Word snippet sets the hyperlink URL of a selected image. 
await Word.run(async (context) => {
    const selection = context.document.getSelection();
    const firstImage = selection.inlinePictures.getFirstOrNullObject();
    await context.sync();

    // Check if an image was selected before changing its property.
    if (!firstImage.isNullObject) {
        firstImage.hyperlink = "https://www.microsoft.com";
    } else {
        console.log("No image selected");
    }

    await context.sync();
});