Word.RangeLocation enum

範囲の場所を表します。 Word などのさまざまなオブジェクトで getRange を呼び出すことで、範囲を取得できます。段落と Word.ContentControl。

注釈

API セット: WordApi 1.3

使用元

例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml

// Gets complete sentences from the insertion point to the end of its paragraph.
await Word.run(async (context) => {
  const selection: Word.Range = context.document.getSelection();
  const sentences: Word.RangeCollection = selection.getTextRanges(["."], false);
  sentences.load("$none");
  await context.sync();

  const firstSentence: Word.Range = sentences.items[0];
  const paragraphEnd: Word.Range = selection.paragraphs.getFirst().getRange(Word.RangeLocation.end);
  const remainingRange: Word.Range = firstSentence.expandTo(paragraphEnd);
  const sentencesToTheEndOfParagraph: Word.RangeCollection = remainingRange.getTextRanges(["."], false);
  sentencesToTheEndOfParagraph.load("text");
  await context.sync();

  console.log("Sentences from the current sentence to the paragraph end:");
  for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) {
    console.log(sentencesToTheEndOfParagraph.items[i].text);
  }
});

フィールド

after = "After"

オブジェクトの後の点。 オブジェクトが段落コンテンツ コントロールまたはテーブル コンテンツ コントロールの場合は、EOP 文字またはテーブル文字の後のポイントです。

before = "Before"

コンテンツ コントロール専用です。 オープニングタグの前のポイントです。

content = "Content"

start から end までの範囲。

end = "End"

オブジェクトの終了点。 段落の場合は、EOP (段落の終わり) の前のポイントです。 コンテンツ コントロールの場合は、終了タグの前のポイントです。

start = "Start"

オブジェクトの開始点。 コンテンツ コントロールの場合は、開始タグの後のポイントです。

whole = "Whole"

オブジェクトの全範囲。 オブジェクトが段落コンテンツ コントロールまたはテーブル コンテンツ コントロールの場合は、コンテンツ コントロールの後の EOP 文字またはテーブル文字も含まれます。