Word.RelativeHorizontalPosition enum

表示形状相对于的水平位置。 有关边距的详细信息,请参阅更改Word文档中的边距。

注解

[ API 集:WordApiDesktop 1.2 ]

示例

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

await Word.run(async (context) => {
  // Changes the position of the first set of grouped shapes (including text boxes) found in the document body.
  const firstShapeGroup: Word.Shape = context.document.body.shapes
    .getByTypes([Word.ShapeType.group])
    .getFirstOrNullObject();
  firstShapeGroup.load("shapeGroup/shapes");
  await context.sync();

  if (firstShapeGroup.isNullObject) {
    console.log("No shape groups found in the document body.");
    return;
  }

  let shapeGroup: Word.ShapeGroup = firstShapeGroup.shapeGroup;
  console.log("About to change the position of the first shape group found in document body:", shapeGroup.shapes);
  firstShapeGroup.relativeVerticalPosition = Word.RelativeVerticalPosition.insideMargin;
  firstShapeGroup.relativeHorizontalPosition = Word.RelativeHorizontalPosition.margin;

  console.log("Changed the position of the first shape group.");
});

字段

character = "Character"

相对于字符。

column = "Column"

相对于列。

insideMargin = "InsideMargin"

相对于内部边距。

leftMargin = "LeftMargin"

相对于左边距。

margin = "Margin"

相对于边距。

outsideMargin = "OutsideMargin"

相对于外部边距。

page = "Page"

相对于页面。

rightMargin = "RightMargin"

相对于右边距。