Word.StyleType enum

スタイルの種類を表します。

注釈

API セット: WordAPI 1.5

使用元

例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/28-formatting/manage-styles.yaml

// Applies the specified style to a paragraph.
await Word.run(async (context) => {
  const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value;
  if (styleName == "") {
    console.warn("Enter a style name to apply.");
    return;
  }

  const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
  style.load("isNullObject, nameLocal, type");
  await context.sync();

  if (style.isNullObject) {
    console.warn(`There's no existing style with the name '${styleName}'.`);
  } else if (style.type != Word.StyleType.paragraph) {
    console.log(`The '${styleName}' style isn't a paragraph style.`);
  } else {
    const body: Word.Body = context.document.body;
    body.clear();
    const paragraph: Word.Paragraph = body.insertParagraph(
      "This paragraph uses a custom style.",
      Word.InsertLocation.start
    );
    paragraph.style = style.nameLocal;
    await context.sync();

    console.log(`Applied '${styleName}' to the sample paragraph.`);
  }
});

フィールド

character = "Character"

スタイルが文字スタイルであることを表します。

list = "List"

スタイルがリスト スタイルであることを表します。 現在、デスクトップでサポートされています。

paragraph = "Paragraph"

スタイルが段落スタイルであることを表します。

table = "Table"

スタイルが表スタイルであることを表します。