Edit

Share via


Word.InsertShapeOptions interface

Specifies the options to determine location and size when inserting a shape.

Remarks

[ API set: WordApiDesktop 1.2 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/45-shapes/manage-shapes-text-boxes.yaml

await Word.run(async (context) => {
  // Inserts a text box at the beginning of the selection.
  const range: Word.Range = context.document.getSelection();
  const insertShapeOptions: Word.InsertShapeOptions = {
    top: 0,
    left: 0,
    height: 100,
    width: 100
  };

  const newTextBox: Word.Shape = range.insertTextBox("placeholder text", insertShapeOptions);
  await context.sync();

  console.log("Inserted a text box at the beginning of the current selection.");
});

Properties

height

If provided, specifies the height of the shape being inserted.

left

If provided, specifies the left position of the shape being inserted.

top

If provided, specifies the top position of the shape being inserted.

width

If provided, specifies the width of the shape being inserted.

Property Details

height

If provided, specifies the height of the shape being inserted.

height?: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.2 ]

left

If provided, specifies the left position of the shape being inserted.

left?: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.2 ]

top

If provided, specifies the top position of the shape being inserted.

top?: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.2 ]

width

If provided, specifies the width of the shape being inserted.

width?: number;

Property Value

number

Remarks

[ API set: WordApiDesktop 1.2 ]