Edit

Share via


Word.Frame class

Represents a frame. The Frame object is a member of the Word.FrameCollection object.

Extends

Remarks

[ API set: WordApiDesktop 1.3 ]

Properties

borders

Returns a BorderUniversalCollection object that represents all the borders for the frame.

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

height

Specifies the height (in points) of the frame.

heightRule

Specifies a FrameSizeRule value that represents the rule for determining the height of the frame.

horizontalDistanceFromText

Specifies the horizontal distance between the frame and the surrounding text, in points.

horizontalPosition

Specifies the horizontal distance between the edge of the frame and the item specified by the relativeHorizontalPosition property.

lockAnchor

Specifies if the frame is locked.

range

Returns a Range object that represents the portion of the document that's contained within the frame.

relativeHorizontalPosition

Specifies the relative horizontal position of the frame.

relativeVerticalPosition

Specifies the relative vertical position of the frame.

shading

Returns a ShadingUniversal object that refers to the shading formatting for the frame.

textWrap

Specifies if document text wraps around the frame.

verticalDistanceFromText

Specifies the vertical distance (in points) between the frame and the surrounding text.

verticalPosition

Specifies the vertical distance between the edge of the frame and the item specified by the relativeVerticalPosition property.

width

Specifies the width (in points) of the frame.

widthRule

Specifies the rule used to determine the width of the frame.

Methods

copy()

Copies the frame to the Clipboard.

cut()

Removes the frame from the document and places it on the Clipboard.

delete()

Deletes the frame.

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

select()

Selects the frame.

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that's passed to it.) Whereas the original Word.Frame object is an API object, the toJSON method returns a plain JavaScript object (typed as Word.Interfaces.FrameData) that contains shallow copies of any loaded child properties from the original object.

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you're using this object across .sync calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you need to add the object to the tracked object collection when the object was first created. If this object is part of a collection, you should also track the parent collection.

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You'll need to call context.sync() before the memory release takes effect.

Property Details

borders

Returns a BorderUniversalCollection object that represents all the borders for the frame.

readonly borders: Word.BorderUniversalCollection;

Property Value

Remarks

[ API set: WordApiDesktop 1.3 ]

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

height

Specifies the height (in points) of the frame.

height: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.3 ]

heightRule

Specifies a FrameSizeRule value that represents the rule for determining the height of the frame.

heightRule: Word.FrameSizeRule | "Auto" | "AtLeast" | "Exact";

Property Value

Word.FrameSizeRule | "Auto" | "AtLeast" | "Exact"

Remarks

[ API set: WordApiDesktop 1.3 ]

horizontalDistanceFromText

Specifies the horizontal distance between the frame and the surrounding text, in points.

horizontalDistanceFromText: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.3 ]

horizontalPosition

Specifies the horizontal distance between the edge of the frame and the item specified by the relativeHorizontalPosition property.

horizontalPosition: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.3 ]

lockAnchor

Specifies if the frame is locked.

lockAnchor: boolean;

Property Value

boolean

Remarks

[ API set: WordApiDesktop 1.3 ]

range

Returns a Range object that represents the portion of the document that's contained within the frame.

readonly range: Word.Range;

Property Value

Remarks

[ API set: WordApiDesktop 1.3 ]

relativeHorizontalPosition

Specifies the relative horizontal position of the frame.

relativeHorizontalPosition: Word.RelativeHorizontalPosition | "Margin" | "Page" | "Column" | "Character" | "LeftMargin" | "RightMargin" | "InsideMargin" | "OutsideMargin";

Property Value

Word.RelativeHorizontalPosition | "Margin" | "Page" | "Column" | "Character" | "LeftMargin" | "RightMargin" | "InsideMargin" | "OutsideMargin"

Remarks

[ API set: WordApiDesktop 1.3 ]

relativeVerticalPosition

Specifies the relative vertical position of the frame.

relativeVerticalPosition: Word.RelativeVerticalPosition | "Margin" | "Page" | "Paragraph" | "Line" | "TopMargin" | "BottomMargin" | "InsideMargin" | "OutsideMargin";

Property Value

Word.RelativeVerticalPosition | "Margin" | "Page" | "Paragraph" | "Line" | "TopMargin" | "BottomMargin" | "InsideMargin" | "OutsideMargin"

Remarks

[ API set: WordApiDesktop 1.3 ]

shading

Returns a ShadingUniversal object that refers to the shading formatting for the frame.

readonly shading: Word.ShadingUniversal;

Property Value

Remarks

[ API set: WordApiDesktop 1.3 ]

textWrap

Specifies if document text wraps around the frame.

textWrap: boolean;

Property Value

boolean

Remarks

[ API set: WordApiDesktop 1.3 ]

verticalDistanceFromText

Specifies the vertical distance (in points) between the frame and the surrounding text.

verticalDistanceFromText: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.3 ]

verticalPosition

Specifies the vertical distance between the edge of the frame and the item specified by the relativeVerticalPosition property.

verticalPosition: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.3 ]

width

Specifies the width (in points) of the frame.

width: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.3 ]

widthRule

Specifies the rule used to determine the width of the frame.

widthRule: Word.FrameSizeRule | "Auto" | "AtLeast" | "Exact";

Property Value

Word.FrameSizeRule | "Auto" | "AtLeast" | "Exact"

Remarks

[ API set: WordApiDesktop 1.3 ]

Method Details

copy()

Copies the frame to the Clipboard.

copy(): void;

Returns

void

Remarks

[ API set: WordApiDesktop 1.3 ]

cut()

Removes the frame from the document and places it on the Clipboard.

cut(): void;

Returns

void

Remarks

[ API set: WordApiDesktop 1.3 ]

delete()

Deletes the frame.

delete(): void;

Returns

void

Remarks

[ API set: WordApiDesktop 1.3 ]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: Word.Interfaces.FrameLoadOptions): Word.Frame;

Parameters

options
Word.Interfaces.FrameLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Word.Frame;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Word.Frame;

Parameters

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

select()

Selects the frame.

select(): void;

Returns

void

Remarks

[ API set: WordApiDesktop 1.3 ]

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.FrameUpdateData, options?: OfficeExtension.UpdateOptions): void;

Parameters

properties
Word.Interfaces.FrameUpdateData

A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

Provides an option to suppress errors if the properties object tries to set any read-only properties.

Returns

void

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Word.Frame): void;

Parameters

properties
Word.Frame

Returns

void

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that's passed to it.) Whereas the original Word.Frame object is an API object, the toJSON method returns a plain JavaScript object (typed as Word.Interfaces.FrameData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Word.Interfaces.FrameData;

Returns

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you're using this object across .sync calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you need to add the object to the tracked object collection when the object was first created. If this object is part of a collection, you should also track the parent collection.

track(): Word.Frame;

Returns

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You'll need to call context.sync() before the memory release takes effect.

untrack(): Word.Frame;

Returns