Word.NoteItem class

脚注または文末脚注を表します。

Extends

注釈

[ API セット: WordApi 1.5 ]

プロパティ

body

メモ項目の body オブジェクトを表します。 脚注または文末脚注内のテキストの部分です。

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

reference

メイン ドキュメントの脚注または文末脚注の参照を表します。

type

脚注または文末脚注の種類を表します。

メソッド

delete()

メモ項目を削除します。

getNext()

同じ型の次のメモ項目を取得します。 このメモ項目が ItemNotFound 最後の項目である場合は、エラーをスローします。

getNextOrNullObject()

同じ型の次のメモ項目を取得します。 このメモ項目が最後のアイテムの場合、このメソッドは プロパティが に設定されたオブジェクトをisNullObjecttrue返します。 詳細については、「 *OrNullObject メソッドとプロパティ」を参照してください。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出toJSONします)。一方、元のWord。NoteItem オブジェクトは API オブジェクトです。メソッドは、元のtoJSONオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (としてWord.Interfaces.NoteItemData型指定) を返します。

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、context.trackedObjects.add(thisObject)の短縮形です。 このオブジェクトを呼び出しで .sync 使用していて、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。 このオブジェクトがコレクションの一部である場合は、親コレクションも追跡する必要があります。

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、context.trackedObjects.remove(thisObject)の短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync() 必要があります。

プロパティの詳細

body

メモ項目の body オブジェクトを表します。 脚注または文末脚注内のテキストの部分です。

readonly body: Word.Body;

プロパティ値

注釈

[ API セット: WordApi 1.5 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml

// Gets the text of the referenced footnote.
await Word.run(async (context) => {
  const footnotes = context.document.body.footnotes;
  footnotes.load("items/body");
  await context.sync();

  const referenceNumber = $("#input-reference").val();
  const mark = (referenceNumber as number) - 1;
  const footnoteBody = footnotes.items[mark].body.getRange();
  footnoteBody.load("text");
  await context.sync();

  console.log(`Text of footnote ${referenceNumber}: ${footnoteBody.text}`);
});

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

reference

メイン ドキュメントの脚注または文末脚注の参照を表します。

readonly reference: Word.Range;

プロパティ値

注釈

[ API セット: WordApi 1.5 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml

// Selects the footnote's reference mark in the document body.
await Word.run(async (context) => {
  const footnotes = context.document.body.footnotes;
  footnotes.load("items/reference");
  await context.sync();

  const referenceNumber = $("#input-reference").val();
  const mark = (referenceNumber as number) - 1;
  const item = footnotes.items[mark];
  const reference = item.reference;
  reference.select();
  await context.sync();

  console.log(`Reference ${referenceNumber} is selected.`);
});

type

脚注または文末脚注の種類を表します。

readonly type: Word.NoteItemType | "Footnote" | "Endnote";

プロパティ値

Word.NoteItemType | "Footnote" | "Endnote"

注釈

[ API セット: WordApi 1.5 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml

// Gets the referenced note's item type and body type, which are both "Footnote".
await Word.run(async (context) => {
  const footnotes = context.document.body.footnotes;
  footnotes.load("items");
  await context.sync();

  const referenceNumber = $("#input-reference").val();
  const mark = (referenceNumber as number) - 1;
  const item = footnotes.items[mark];
  console.log(`Note type of footnote ${referenceNumber}: ${item.type}`);

  item.body.load("type");
  await context.sync();

  console.log(`Body type of note: ${item.body.type}`);
});

メソッドの詳細

delete()

メモ項目を削除します。

delete(): void;

戻り値

void

注釈

[ API セット: WordApi 1.5 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml

// Deletes this referenced footnote.
await Word.run(async (context) => {
  const footnotes = context.document.body.footnotes;
  footnotes.load("items");
  await context.sync();

  const referenceNumber = $("#input-reference").val();
  const mark = (referenceNumber as number) - 1;
  footnotes.items[mark].delete();
  await context.sync();

  console.log("Footnote deleted.");
});

getNext()

同じ型の次のメモ項目を取得します。 このメモ項目が ItemNotFound 最後の項目である場合は、エラーをスローします。

getNext(): Word.NoteItem;

戻り値

注釈

[ API セット: WordApi 1.5 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-footnotes.yaml

// Selects the next footnote in the document body.
await Word.run(async (context) => {
  const footnotes = context.document.body.footnotes;
  footnotes.load("items/reference");
  await context.sync();

  const referenceNumber = $("#input-reference").val();
  const mark = (referenceNumber as number) - 1;
  const reference = footnotes.items[mark].getNext().reference;
  reference.select();
  console.log("Selected is the next footnote: " + (mark + 2));
});

getNextOrNullObject()

同じ型の次のメモ項目を取得します。 このメモ項目が最後のアイテムの場合、このメソッドは プロパティが に設定されたオブジェクトをisNullObjecttrue返します。 詳細については、「 *OrNullObject メソッドとプロパティ」を参照してください。

getNextOrNullObject(): Word.NoteItem;

戻り値

注釈

[ API セット: WordApi 1.5 ]

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: Word.Interfaces.NoteItemLoadOptions): Word.NoteItem;

パラメーター

options
Word.Interfaces.NoteItemLoadOptions

読み込むオブジェクトのプロパティのオプションを提供します。

戻り値

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

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

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。

戻り値

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

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

パラメーター

propertyNamesAndPaths

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

propertyNamesAndPaths.select は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand 、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。

戻り値

set(properties, options)

オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。

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

パラメーター

properties
Word.Interfaces.NoteItemUpdateData

メソッドが呼び出されるオブジェクトのプロパティに等形的に構造化されたプロパティを持つ JavaScript オブジェクト。

options
OfficeExtension.UpdateOptions

properties オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。

戻り値

void

set(properties)

既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。

set(properties: Word.NoteItem): void;

パラメーター

properties
Word.NoteItem

戻り値

void

toJSON()

API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドを JSON.stringify()オーバーライドします。 (JSON.stringifyさらに、渡される オブジェクトの メソッドを呼び出toJSONします)。一方、元のWord。NoteItem オブジェクトは API オブジェクトです。メソッドは、元のtoJSONオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (としてWord.Interfaces.NoteItemData型指定) を返します。

toJSON(): Word.Interfaces.NoteItemData;

戻り値

track()

ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、context.trackedObjects.add(thisObject)の短縮形です。 このオブジェクトを呼び出しで .sync 使用していて、".run" バッチのシーケンシャル実行の外部で使用していて、プロパティを設定するとき、またはオブジェクトのメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。 このオブジェクトがコレクションの一部である場合は、親コレクションも追跡する必要があります。

track(): Word.NoteItem;

戻り値

untrack()

前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、context.trackedObjects.remove(thisObject)の短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に を呼び出す context.sync() 必要があります。

untrack(): Word.NoteItem;

戻り値