Word.Paragraph class
選択部分、範囲、コンテンツ コントロール、または文書本文に含まれる 1 つの段落を表します。
- Extends
注釈
使用元
- Word.本文: insertParagraph
- Word.ContentControl: insertParagraph
- Word.ドキュメント: getParagraphByUniqueLocalId
- Word.InlinePicture: insertParagraph, paragraph
- Word.リスト: insertParagraph
- Word.ListItem: getAncestor、getAncestorOrNullObject
- Word.ParagraphCollection: add, getFirst, getFirstOrNullObject, getLast, getLastOrNullObject, items
- Word.範囲: insertParagraph
- Word.テーブル: getParagraphAfter、getParagraphAfterOrNullObject、getParagraphBefore、getParagraphBeforeOrNullObject、insertParagraph
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml
await Word.run(async (context) => {
// The collection of paragraphs of the current selection returns the full paragraphs contained in it.
const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst();
paragraph.load("text");
await context.sync();
console.log(paragraph.text);
});
プロパティ
| alignment | 段落の配置を指定します。 値には、 |
| borders | 段落のすべての境界線を表す |
| content |
段落内の |
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| endnotes | 段落内の文末脚注のコレクションを取得します。 |
| fields | 段落内のフィールドのコレクションを取得します。 |
| first |
1 行目またはぶら下げているインデントの値をポイント単位で指定します。 最初の行のインデントを設定するのには正の値を使用し、ぶら下げインデントを設定するのには負の値を使用します。 |
| font | 段落のテキスト形式を取得します。 これを使用して、フォント名、サイズ、色、およびその他のプロパティを取得および設定します。 |
| footnotes | 段落内の脚注のコレクションを取得します。 |
| inline |
段落内の |
| is |
段落がその親の本文内の最後の段落であることを示します。 |
| is |
段落がリスト アイテムであるかどうかを確認します。 |
| left |
段落の左インデント値を指定します (ポイント単位)。 |
| line |
指定した段落の行間隔をポイント単位で指定します。 Word UI では、この値が 12 で除算されます。 |
| line |
段落の後の間隔の長さをグリッド線で指定します。 |
| line |
段落の前の間隔をグリッド線で指定します。 |
| list | この段落が属するリストを取得します。 段落がリストにない場合は |
| list |
段落の ListItem を取得します。 段落がリストに含まれていない場合は、 |
| list |
段落の ListItem を取得します。 段落がリストの一部ではない場合、このメソッドは |
| list |
この段落が属するリストを取得します。 段落がリスト内にない場合、このメソッドは |
| outline |
段落のアウトライン レベルを指定します。 |
| parent |
段落の親の本文を取得します。 |
| parent |
段落を格納しているコンテンツ コントロールを取得します。 親コンテンツ コントロールがない場合は |
| parent |
段落を格納しているコンテンツ コントロールを取得します。 親コンテンツ コントロールがない場合、このメソッドは、 |
| parent |
段落を含むテーブルを取得します。 テーブルに含まれない場合は、 |
| parent |
段落を含むテーブルのセルを取得します。 テーブル セルに含まれない場合は、 |
| parent |
段落を含むテーブルのセルを取得します。 テーブルのセルに含まれない場合、このメソッドは、 |
| parent |
段落を含むテーブルを取得します。 テーブルに含まれない場合、このメソッドは |
| right |
段落の右インデント値を指定します (ポイント単位)。 |
| shading | 段落の網かけ形式を参照する |
| shapes | インライン図形とフローティング図形の両方を含む、段落に固定されている |
| space |
段落の後の間隔を指定します (ポイント単位)。 |
| space |
段落の前の間隔を指定します (ポイント単位)。 |
| style | 段落のスタイル名を指定します。 カスタム スタイルとローカライズされたスタイルの名前には、このプロパティを使用します。 ロケール間で移植可能な組み込みスタイルを使用するには、"styleBuiltIn" プロパティを参照してください。 |
| style |
段落の組み込みスタイル名を指定します。 ロケール間で移植可能な組み込みスタイルの場合は、このプロパティを使用します。 カスタム スタイルまたはローカライズされたスタイルの名前を使用するには、"style" プロパティを参照してください。 |
| table |
段落のテーブルのレベルを取得します。 段落が表内にない場合は 0 を返します。 |
| text | 段落のテキストを取得します。 |
| unique |
現在のセッションの段落識別子を表す文字列を取得します。 ID は、中かっこのない標準の 8-4-4-4-12 GUID 形式であり、セッションおよび共同作成者によって異なります。 |
メソッド
| attach |
指定したレベルで段落を既存のリストに結合させます。 段落をリストに結合できない場合、または段落が既にリスト アイテムである場合は、失敗します。 |
| clear() |
|
| close |
段落の前のスペースを削除します。 |
| delete() | 文書から段落と、その段落の内容を削除します。 |
| detach |
段落がリスト アイテムである場合は、この段落をリストから移動します。 |
| get |
この |
| get |
段落に関連付けられているコメントを取得します。 |
| get |
段落内の現在サポートされているコンテンツ コントロールを取得します。 |
| get |
|
| get |
次の段落を取得します。 段落が最後の段落の場合は |
| get |
次の段落を取得します。 段落が最後の段落の場合、このメソッドは |
| get |
|
| get |
前の段落を取得します。 段落が最初の段落の場合は |
| get |
前の段落を取得します。 段落が最初の段落の場合、このメソッドは |
| get |
段落全体、あるいは段落の開始点または終了点を範囲として取得します。 |
| get |
|
| get |
|
| get |
段落のテキストを返します。 これには、数式、グラフィックス (画像、ビデオ、描画など)、およびさまざまなコンテンツをマークする特殊文字 (コンテンツ コントロール、フィールド、コメント、脚注、文末脚注など) は含まれません。 既定では、隠しテキストと削除済みとマークされたテキストは除外されます。 |
| get |
句読点やその他の終了記号を使用して、段落内のテキスト範囲を取得します。 |
| get |
段落内の |
| indent() | 段落を 1 レベルインデントします。 |
| indent |
指定した文字数だけ段落をインデントします。 |
| indent |
段落の最初の行を指定された文字数だけインデントします。 |
| insert |
この |
| insert |
メイン文書の指定した位置に、区切りを挿入します。 |
| insert |
アンカーを段落の先頭に配置して、テキストの前にフローティング キャンバスを挿入します。 |
| insert |
|
| insert |
指定した位置にある段落にドキュメントを挿入します。 |
| insert |
テキストの前に幾何学図形を挿入し、アンカーを段落の先頭に配置します。 |
| insert |
テキストの前に幾何学図形を挿入し、アンカーを段落の先頭に配置します。 |
| insert |
段落の指定した位置に、HTML を挿入します。 |
| insert |
段落の指定した位置に、図を挿入します。 |
| insert |
指定した位置の段落に OOXML を挿入します。 |
| insert |
指定した位置に、段落を挿入します。 |
| insert |
アンカーを段落の先頭に配置して、テキストの前に浮動画像を挿入します。 |
| insert |
指定した数の行と列を含むテーブルを挿入します。 |
| insert |
段落の指定した位置に、テキストを挿入します。 |
| insert |
テキストの前にフローティング テキスト ボックスを挿入し、アンカーを段落の先頭に配置します。 |
| join |
この段落の上または下に最も近いリストを持つリスト段落を結合します。 |
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| next(count) | 次の段落を示す |
| open |
段落の前の間隔を切り替えます。 |
| open |
段落前の間隔を 12 ポイントに設定します。 |
| outdent() | 段落のインデントを 1 レベル削除します。 |
| outline |
次の見出しレベル スタイル (見出し 1 から見出し 8) を段落に適用します。 |
| outline |
標準スタイルを適用して、段落を本文テキストに降格します。 |
| outline |
前の見出しレベル スタイル (見出し 1 から見出し 8) を段落に適用します。 |
| previous(count) | 前の段落を |
| reset() | 手動で指定した段落書式 (スタイルを使わずに設定した書式) を削除します。 |
| reset |
カスタム リスト レベルを使用する段落を元のレベル設定にリセットします。 |
| search(search |
|
| select(selection |
段落を選択して、その段落に Word の UI を移動します。 |
| select(selection |
段落を選択して、その段落に Word の UI を移動します。 |
| select |
箇条書きの段落番号または行頭文字を選択します。 |
| separate |
1 つのリストを 2 つのリストに分割します。 段落番号の場合、新しいリストは開始番号 (通常 1) から番号付けが再開されます。 |
| set(properties, options) | オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクト、または同じ型の別の API オブジェクトを渡すことができます。 |
| set(properties) | 既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。 |
| space1() | 段落をシングル スペースに設定します。 |
| space1Pt5() | 段落を 1.5 行間隔に設定します。 |
| space2() | 段落をダブル スペースに設定します。 |
| split(delimiters, trim |
区切り記号を使用して、段落を子の範囲に分割します。 |
| start |
この段落を含む新しいリストを開始します。 段落が既にリスト アイテムである場合は失敗します。 |
| tab |
指定されたタブ位置にぶら下げインデントを設定します。 |
| tab |
段落の左インデントを、指定したタブ位置の数に設定します。 |
| toJSON() | API オブジェクトが |
| track() | ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject) の短縮形です。 このオブジェクトを |
| untrack() | 前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、 context.trackedObjects.remove(thisObject) の省略形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ リリースを有効にする前に、 |
イベント
| on |
新しいコメントが追加されたときに発生します。 |
| on |
コメントまたはその応答が変更されたときに発生します。 |
| on |
コメントが削除されたときに発生します。 |
| on |
コメントの選択が解除されたときに発生します。 |
| on |
コメントが選択されているときに発生します。 |
プロパティの詳細
alignment
段落の配置を指定します。 値には、 left、 centered、 right、または justified を指定できます。
alignment: Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified";
プロパティ値
Word.Alignment | "Mixed" | "Unknown" | "Left" | "Centered" | "Right" | "Justified"
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml
await Word.run(async (context) => {
// Center last paragraph alignment.
context.document.body.paragraphs.getLast().alignment = "Centered";
await context.sync();
});
borders
段落のすべての境界線を表す BorderUniversalCollection オブジェクトを返します。
readonly borders: Word.BorderUniversalCollection;
プロパティ値
注釈
contentControls
段落内の ContentControl オブジェクトのコレクションを取得します。
readonly contentControls: Word.ContentControlCollection;
プロパティ値
注釈
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
endnotes
段落内の文末脚注のコレクションを取得します。
readonly endnotes: Word.NoteItemCollection;
プロパティ値
注釈
fields
段落内のフィールドのコレクションを取得します。
readonly fields: Word.FieldCollection;
プロパティ値
注釈
firstLineIndent
1 行目またはぶら下げているインデントの値をポイント単位で指定します。 最初の行のインデントを設定するのには正の値を使用し、ぶら下げインデントを設定するのには負の値を使用します。
firstLineIndent: number;
プロパティ値
number
注釈
font
段落のテキスト形式を取得します。 これを使用して、フォント名、サイズ、色、およびその他のプロパティを取得および設定します。
readonly font: Word.Font;
プロパティ値
注釈
footnotes
段落内の脚注のコレクションを取得します。
readonly footnotes: Word.NoteItemCollection;
プロパティ値
注釈
inlinePictures
段落内の InlinePicture オブジェクトのコレクションを取得します。 コレクションには、フローティング イメージは含まれません。
readonly inlinePictures: Word.InlinePictureCollection;
プロパティ値
注釈
isLastParagraph
段落がその親の本文内の最後の段落であることを示します。
readonly isLastParagraph: boolean;
プロパティ値
boolean
注釈
isListItem
leftIndent
段落の左インデント値を指定します (ポイント単位)。
leftIndent: number;
プロパティ値
number
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml
await Word.run(async (context) => {
// Indent the first paragraph.
context.document.body.paragraphs.getFirst().leftIndent = 75; //units = points
return context.sync();
});
lineSpacing
指定した段落の行間隔をポイント単位で指定します。 Word UI では、この値が 12 で除算されます。
lineSpacing: number;
プロパティ値
number
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml
await Word.run(async (context) => {
// Adjust line spacing.
context.document.body.paragraphs.getFirst().lineSpacing = 20;
await context.sync();
});
lineUnitAfter
段落の後の間隔の長さをグリッド線で指定します。
lineUnitAfter: number;
プロパティ値
number
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml
await Word.run(async (context) => {
// Set the space (in line units) after the first paragraph.
context.document.body.paragraphs.getFirst().lineUnitAfter = 1;
await context.sync();
});
lineUnitBefore
段落の前の間隔をグリッド線で指定します。
lineUnitBefore: number;
プロパティ値
number
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml
await Word.run(async (context) => {
// Set the space (in line units) before the first paragraph.
context.document.body.paragraphs.getFirst().lineUnitBefore = 1;
await context.sync();
});
list
この段落が属するリストを取得します。 段落がリストにない場合は ItemNotFound エラーをスローします。
readonly list: Word.List;
プロパティ値
注釈
listItem
段落の ListItem を取得します。 段落がリストに含まれていない場合は、 ItemNotFound エラーをスローします。
readonly listItem: Word.ListItem;
プロパティ値
注釈
listItemOrNullObject
段落の ListItem を取得します。 段落がリストの一部ではない場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
readonly listItemOrNullObject: Word.ListItem;
プロパティ値
注釈
listOrNullObject
この段落が属するリストを取得します。 段落がリスト内にない場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
readonly listOrNullObject: Word.List;
プロパティ値
注釈
outlineLevel
parentBody
parentContentControl
段落を格納しているコンテンツ コントロールを取得します。 親コンテンツ コントロールがない場合は ItemNotFound エラーをスローします。
readonly parentContentControl: Word.ContentControl;
プロパティ値
注釈
parentContentControlOrNullObject
段落を格納しているコンテンツ コントロールを取得します。 親コンテンツ コントロールがない場合、このメソッドは、 isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
readonly parentContentControlOrNullObject: Word.ContentControl;
プロパティ値
注釈
parentTable
段落を含むテーブルを取得します。 テーブルに含まれない場合は、 ItemNotFound エラーをスローします。
readonly parentTable: Word.Table;
プロパティ値
注釈
parentTableCell
段落を含むテーブルのセルを取得します。 テーブル セルに含まれない場合は、 ItemNotFound エラーをスローします。
readonly parentTableCell: Word.TableCell;
プロパティ値
注釈
parentTableCellOrNullObject
段落を含むテーブルのセルを取得します。 テーブルのセルに含まれない場合、このメソッドは、 isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
readonly parentTableCellOrNullObject: Word.TableCell;
プロパティ値
注釈
parentTableOrNullObject
段落を含むテーブルを取得します。 テーブルに含まれない場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
readonly parentTableOrNullObject: Word.Table;
プロパティ値
注釈
rightIndent
shading
段落の網かけ形式を参照する ShadingUniversal オブジェクトを返します。
readonly shading: Word.ShadingUniversal;
プロパティ値
注釈
shapes
インライン図形とフローティング図形の両方を含む、段落に固定されている Shape オブジェクトのコレクションを取得します。 現時点では、テキスト ボックス、幾何学的図形、グループ、画像、キャンバスの図形のみがサポートされています。
readonly shapes: Word.ShapeCollection;
プロパティ値
注釈
重要: 時間の経過とともに、追加の種類の図形がサポートされる場合があることに注意してください。 そのため、アドインでは特定の種類の図形を要求および処理する必要があります。
spaceAfter
段落の後の間隔を指定します (ポイント単位)。
spaceAfter: number;
プロパティ値
number
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/paragraph-properties.yaml
await Word.run(async (context) => {
// Set the space (in points) after the first paragraph.
context.document.body.paragraphs.getFirst().spaceAfter = 20;
await context.sync();
});
spaceBefore
style
段落のスタイル名を指定します。 カスタム スタイルとローカライズされたスタイルの名前には、このプロパティを使用します。 ロケール間で移植可能な組み込みスタイルを使用するには、"styleBuiltIn" プロパティを参照してください。
style: string;
プロパティ値
string
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/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();
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();
body.insertParagraph(
"Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.",
"Start"
);
const paragraph: Word.Paragraph = body.paragraphs.getFirst();
paragraph.style = style.nameLocal;
console.log(`'${styleName}' style applied to first paragraph.`);
}
});
styleBuiltIn
段落の組み込みスタイル名を指定します。 ロケール間で移植可能な組み込みスタイルの場合は、このプロパティを使用します。 カスタム スタイルまたはローカライズされたスタイルの名前を使用するには、"style" プロパティを参照してください。
styleBuiltIn: Word.BuiltInStyleName | "Other" | "Normal" | "Heading1" | "Heading2" | "Heading3" | "Heading4" | "Heading5" | "Heading6" | "Heading7" | "Heading8" | "Heading9" | "Toc1" | "Toc2" | "Toc3" | "Toc4" | "Toc5" | "Toc6" | "Toc7" | "Toc8" | "Toc9" | "FootnoteText" | "Header" | "Footer" | "Caption" | "FootnoteReference" | "EndnoteReference" | "EndnoteText" | "Title" | "Subtitle" | "Hyperlink" | "Strong" | "Emphasis" | "NoSpacing" | "ListParagraph" | "Quote" | "IntenseQuote" | "SubtleEmphasis" | "IntenseEmphasis" | "SubtleReference" | "IntenseReference" | "BookTitle" | "Bibliography" | "TocHeading" | "TableGrid" | "PlainTable1" | "PlainTable2" | "PlainTable3" | "PlainTable4" | "PlainTable5" | "TableGridLight" | "GridTable1Light" | "GridTable1Light_Accent1" | "GridTable1Light_Accent2" | "GridTable1Light_Accent3" | "GridTable1Light_Accent4" | "GridTable1Light_Accent5" | "GridTable1Light_Accent6" | "GridTable2" | "GridTable2_Accent1" | "GridTable2_Accent2" | "GridTable2_Accent3" | "GridTable2_Accent4" | "GridTable2_Accent5" | "GridTable2_Accent6" | "GridTable3" | "GridTable3_Accent1" | "GridTable3_Accent2" | "GridTable3_Accent3" | "GridTable3_Accent4" | "GridTable3_Accent5" | "GridTable3_Accent6" | "GridTable4" | "GridTable4_Accent1" | "GridTable4_Accent2" | "GridTable4_Accent3" | "GridTable4_Accent4" | "GridTable4_Accent5" | "GridTable4_Accent6" | "GridTable5Dark" | "GridTable5Dark_Accent1" | "GridTable5Dark_Accent2" | "GridTable5Dark_Accent3" | "GridTable5Dark_Accent4" | "GridTable5Dark_Accent5" | "GridTable5Dark_Accent6" | "GridTable6Colorful" | "GridTable6Colorful_Accent1" | "GridTable6Colorful_Accent2" | "GridTable6Colorful_Accent3" | "GridTable6Colorful_Accent4" | "GridTable6Colorful_Accent5" | "GridTable6Colorful_Accent6" | "GridTable7Colorful" | "GridTable7Colorful_Accent1" | "GridTable7Colorful_Accent2" | "GridTable7Colorful_Accent3" | "GridTable7Colorful_Accent4" | "GridTable7Colorful_Accent5" | "GridTable7Colorful_Accent6" | "ListTable1Light" | "ListTable1Light_Accent1" | "ListTable1Light_Accent2" | "ListTable1Light_Accent3" | "ListTable1Light_Accent4" | "ListTable1Light_Accent5" | "ListTable1Light_Accent6" | "ListTable2" | "ListTable2_Accent1" | "ListTable2_Accent2" | "ListTable2_Accent3" | "ListTable2_Accent4" | "ListTable2_Accent5" | "ListTable2_Accent6" | "ListTable3" | "ListTable3_Accent1" | "ListTable3_Accent2" | "ListTable3_Accent3" | "ListTable3_Accent4" | "ListTable3_Accent5" | "ListTable3_Accent6" | "ListTable4" | "ListTable4_Accent1" | "ListTable4_Accent2" | "ListTable4_Accent3" | "ListTable4_Accent4" | "ListTable4_Accent5" | "ListTable4_Accent6" | "ListTable5Dark" | "ListTable5Dark_Accent1" | "ListTable5Dark_Accent2" | "ListTable5Dark_Accent3" | "ListTable5Dark_Accent4" | "ListTable5Dark_Accent5" | "ListTable5Dark_Accent6" | "ListTable6Colorful" | "ListTable6Colorful_Accent1" | "ListTable6Colorful_Accent2" | "ListTable6Colorful_Accent3" | "ListTable6Colorful_Accent4" | "ListTable6Colorful_Accent5" | "ListTable6Colorful_Accent6" | "ListTable7Colorful" | "ListTable7Colorful_Accent1" | "ListTable7Colorful_Accent2" | "ListTable7Colorful_Accent3" | "ListTable7Colorful_Accent4" | "ListTable7Colorful_Accent5" | "ListTable7Colorful_Accent6";
プロパティ値
Word.BuiltInStyleName | "Other" | "Normal" | "Heading1" | "Heading2" | "Heading3" | "Heading4" | "Heading5" | "Heading6" | "Heading7" | "Heading8" | "Heading9" | "Toc1" | "Toc2" | "Toc3" | "Toc4" | "Toc5" | "Toc6" | "Toc7" | "Toc8" | "Toc9" | "FootnoteText" | "Header" | "Footer" | "Caption" | "FootnoteReference" | "EndnoteReference" | "EndnoteText" | "Title" | "Subtitle" | "Hyperlink" | "Strong" | "Emphasis" | "NoSpacing" | "ListParagraph" | "Quote" | "IntenseQuote" | "SubtleEmphasis" | "IntenseEmphasis" | "SubtleReference" | "IntenseReference" | "BookTitle" | "Bibliography" | "TocHeading" | "TableGrid" | "PlainTable1" | "PlainTable2" | "PlainTable3" | "PlainTable4" | "PlainTable5" | "TableGridLight" | "GridTable1Light" | "GridTable1Light_Accent1" | "GridTable1Light_Accent2" | "GridTable1Light_Accent3" | "GridTable1Light_Accent4" | "GridTable1Light_Accent5" | "GridTable1Light_Accent6" | "GridTable2" | "GridTable2_Accent1" | "GridTable2_Accent2" | "GridTable2_Accent3" | "GridTable2_Accent4" | "GridTable2_Accent5" | "GridTable2_Accent6" | "GridTable3" | "GridTable3_Accent1" | "GridTable3_Accent2" | "GridTable3_Accent3" | "GridTable3_Accent4" | "GridTable3_Accent5" | "GridTable3_Accent6" | "GridTable4" | "GridTable4_Accent1" | "GridTable4_Accent2" | "GridTable4_Accent3" | "GridTable4_Accent4" | "GridTable4_Accent5" | "GridTable4_Accent6" | "GridTable5Dark" | "GridTable5Dark_Accent1" | "GridTable5Dark_Accent2" | "GridTable5Dark_Accent3" | "GridTable5Dark_Accent4" | "GridTable5Dark_Accent5" | "GridTable5Dark_Accent6" | "GridTable6Colorful" | "GridTable6Colorful_Accent1" | "GridTable6Colorful_Accent2" | "GridTable6Colorful_Accent3" | "GridTable6Colorful_Accent4" | "GridTable6Colorful_Accent5" | "GridTable6Colorful_Accent6" | "GridTable7Colorful" | "GridTable7Colorful_Accent1" | "GridTable7Colorful_Accent2" | "GridTable7Colorful_Accent3" | "GridTable7Colorful_Accent4" | "GridTable7Colorful_Accent5" | "GridTable7Colorful_Accent6" | "ListTable1Light" | "ListTable1Light_Accent1" | "ListTable1Light_Accent2" | "ListTable1Light_Accent3" | "ListTable1Light_Accent4" | "ListTable1Light_Accent5" | "ListTable1Light_Accent6" | "ListTable2" | "ListTable2_Accent1" | "ListTable2_Accent2" | "ListTable2_Accent3" | "ListTable2_Accent4" | "ListTable2_Accent5" | "ListTable2_Accent6" | "ListTable3" | "ListTable3_Accent1" | "ListTable3_Accent2" | "ListTable3_Accent3" | "ListTable3_Accent4" | "ListTable3_Accent5" | "ListTable3_Accent6" | "ListTable4" | "ListTable4_Accent1" | "ListTable4_Accent2" | "ListTable4_Accent3" | "ListTable4_Accent4" | "ListTable4_Accent5" | "ListTable4_Accent6" | "ListTable5Dark" | "ListTable5Dark_Accent1" | "ListTable5Dark_Accent2" | "ListTable5Dark_Accent3" | "ListTable5Dark_Accent4" | "ListTable5Dark_Accent5" | "ListTable5Dark_Accent6" | "ListTable6Colorful" | "ListTable6Colorful_Accent1" | "ListTable6Colorful_Accent2" | "ListTable6Colorful_Accent3" | "ListTable6Colorful_Accent4" | "ListTable6Colorful_Accent5" | "ListTable6Colorful_Accent6" | "ListTable7Colorful" | "ListTable7Colorful_Accent1" | "ListTable7Colorful_Accent2" | "ListTable7Colorful_Accent3" | "ListTable7Colorful_Accent4" | "ListTable7Colorful_Accent5" | "ListTable7Colorful_Accent6"
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/doc-assembly.yaml
await Word.run(async (context) => {
const paragraph: Word.Paragraph = context.document.body.insertParagraph("Timeline", "End");
paragraph.styleBuiltIn = "Heading2";
const paragraph2: Word.Paragraph = context.document.body.insertParagraph("The Services shall commence on July 31, 2015, and shall continue through July 29, 2015.", "End");
paragraph2.styleBuiltIn = "Normal";
const paragraph3: Word.Paragraph = context.document.body.insertParagraph("Project Costs by Phase", "End");
paragraph3.styleBuiltIn = "Heading2";
// Note a content control with the title of "ProjectCosts" is added. Content will be replaced later.
const paragraph4: Word.Paragraph = context.document.body.insertParagraph("<Add Project Costs Here>", "End");
paragraph4.styleBuiltIn = "Normal";
paragraph4.font.highlightColor = "#FFFF00";
const contentControl: Word.ContentControl = paragraph4.insertContentControl();
contentControl.title = "ProjectCosts";
const paragraph5: Word.Paragraph = context.document.body.insertParagraph("Project Team", "End");
paragraph5.styleBuiltIn = "Heading2";
paragraph5.font.highlightColor = "#FFFFFF";
const paragraph6: Word.Paragraph = context.document.body.insertParagraph("Terms of Work", "End");
paragraph6.styleBuiltIn = "Heading1";
const paragraph7: Word.Paragraph = context.document.body.insertParagraph("Contractor shall provide the Services and Deliverable(s) as follows:", "End");
paragraph7.styleBuiltIn = "Normal";
const paragraph8: Word.Paragraph = context.document.body.insertParagraph("Out-of-Pocket Expenses / Invoice Procedures", "End");
paragraph8.styleBuiltIn = "Heading2";
const paragraph9 : Word.Paragraph= context.document.body.insertParagraph("Client will be invoiced monthly for the consulting services and T&L expenses. Standard Contractor invoicing is assumed to be acceptable. Invoices are due upon receipt. client will be invoiced all costs associated with out-of-pocket expenses (including, without limitation, costs and expenses associated with meals, lodging, local transportation and any other applicable business expenses) listed on the invoice as a separate line item. Reimbursement for out-of-pocket expenses in connection with performance of this SOW, when authorized and up to the limits set forth in this SOW, shall be in accordance with Client's then-current published policies governing travel and associated business expenses, which information shall be provided by the Client Project Manager.", "End");
paragraph9.styleBuiltIn = "Normal";
// Insert a page break at the end of the document.
context.document.body.insertBreak("Page", "End");
await context.sync();
});
tableNestingLevel
段落のテーブルのレベルを取得します。 段落が表内にない場合は 0 を返します。
readonly tableNestingLevel: number;
プロパティ値
number
注釈
text
段落のテキストを取得します。
readonly text: string;
プロパティ値
string
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml
await Word.run(async (context) => {
// The collection of paragraphs of the current selection returns the full paragraphs contained in it.
const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst();
paragraph.load("text");
await context.sync();
console.log(paragraph.text);
});
uniqueLocalId
現在のセッションの段落識別子を表す文字列を取得します。 ID は、中かっこのない標準の 8-4-4-4-12 GUID 形式であり、セッションおよび共同作成者によって異なります。
readonly uniqueLocalId: string;
プロパティ値
string
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml
// Registers event handlers.
await Word.run(async (context) => {
eventContexts[0] = context.document.onParagraphAdded.add(paragraphChanged);
eventContexts[1] = context.document.onParagraphChanged.add(paragraphChanged);
eventContexts[2] = context.document.onAnnotationClicked.add(onClickedHandler);
eventContexts[3] = context.document.onAnnotationHovered.add(onHoveredHandler);
eventContexts[4] = context.document.onAnnotationInserted.add(onInsertedHandler);
eventContexts[5] = context.document.onAnnotationRemoved.add(onRemovedHandler);
eventContexts[6] = context.document.onAnnotationPopupAction.add(onPopupActionHandler);
await context.sync();
console.log("Event handlers registered.");
});
...
async function paragraphChanged(args: Word.ParagraphChangedEventArgs) {
await Word.run(async (context) => {
const results = [];
for (let id of args.uniqueLocalIds) {
let para = context.document.getParagraphByUniqueLocalId(id);
para.load("uniqueLocalId");
results.push({ para: para, text: para.getText() });
}
await context.sync();
for (let result of results) {
console.log(`${args.type}: ID ${result.para.uniqueLocalId}:-`, result.text.value);
}
});
}
メソッドの詳細
attachToList(listId, level)
指定したレベルで段落を既存のリストに結合させます。 段落をリストに結合できない場合、または段落が既にリスト アイテムである場合は、失敗します。
attachToList(listId: number, level: number): Word.List;
パラメーター
- listId
-
number
既存のリストの ID。
- level
-
number
リスト内のレベル。
返品
注釈
clear()
Paragraph オブジェクトの内容をクリアします。 ユーザーは、消去された内容を元に戻す操作を実行できます。
clear(): void;
返品
void
注釈
例
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the paragraphs collection.
const paragraphs = context.document.body.paragraphs;
// Queue a command to load the style property for all of the paragraphs.
paragraphs.load('style');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
// Queue a command to clear the contents of the first paragraph.
paragraphs.items[0].clear();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Cleared the contents of the first paragraph.');
});
closeUp()
delete()
文書から段落と、その段落の内容を削除します。
delete(): void;
返品
void
注釈
例
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the paragraphs collection.
const paragraphs = context.document.body.paragraphs;
// Queue a command to load the text property for all of the paragraphs.
paragraphs.load('text');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
// Queue a command to delete the first paragraph.
paragraphs.items[0].delete();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Deleted the first paragraph.');
});
detachFromList()
getAnnotations()
この Paragraph オブジェクトに設定された注釈を取得します。
getAnnotations(): Word.AnnotationCollection;
返品
注釈
重要: 基になるサービスの要件により、この API が正常に動作するには Microsoft 365 サブスクリプションが必要です。 詳細については、 GitHub の問題 4953 を参照してください。
getComments()
段落に関連付けられているコメントを取得します。
getComments(): Word.CommentCollection;
返品
注釈
getContentControls(options)
段落内の現在サポートされているコンテンツ コントロールを取得します。
getContentControls(options?: Word.ContentControlOptions): Word.ContentControlCollection;
パラメーター
- options
- Word.ContentControlOptions
省略可能。 返されるコンテンツ コントロールを定義するオプション。
返品
注釈
重要: options パラメーターに特定の型が指定されている場合、サポートされている型のコンテンツ コントロールのみが返されます。 汎用 Word のメソッドを使用すると例外がスローされることに注意してください。特定の型に関連しない ContentControl。 時間の経過とともに、追加の種類のコンテンツ コントロールがサポートされる可能性があります。 そのため、アドインでは、特定の種類のコンテンツ コントロールを要求および処理する必要があります。
getHtml()
Paragraph オブジェクトの HTML 表現を取得します。 Web ページまたは HTML ビューアーで表示すると、書式設定はドキュメントの書式設定とほぼ一致しますが、完全ではありません。 このメソッドでは、異なるプラットフォーム (Windows、Mac、Web 上の Word など) 上の同じドキュメントに対してまったく同じ HTML は返されません。 プラットフォーム間で正確な忠実性や一貫性が必要な場合は、 Paragraph.getOoxml() を使用して返される XML を HTML に変換します。
getHtml(): OfficeExtension.ClientResult<string>;
返品
OfficeExtension.ClientResult<string>
注釈
例
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the paragraphs collection.
const paragraphs = context.document.body.paragraphs;
// Queue a command to load the style property for all of the paragraphs.
paragraphs.load('style');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
// Queue a set of commands to get the HTML of the first paragraph.
const html = paragraphs.items[0].getHtml();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Paragraph HTML: ' + html.value);
});
getNext()
次の段落を取得します。 段落が最後の段落の場合は ItemNotFound エラーをスローします。
getNext(): Word.Paragraph;
返品
注釈
getNextOrNullObject()
次の段落を取得します。 段落が最後の段落の場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
getNextOrNullObject(): Word.Paragraph;
返品
注釈
getOoxml()
Paragraph オブジェクトの Office Open XML (OOXML) 表現を取得します。
getOoxml(): OfficeExtension.ClientResult<string>;
返品
OfficeExtension.ClientResult<string>
注釈
例
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the paragraphs collection.
const paragraphs = context.document.body.paragraphs;
// Queue a command to load the style property for the top 2 paragraphs.
paragraphs.load({select: 'style', top: 2} );
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
// Queue a set of commands to get the OOXML of the first paragraph.
const ooxml = paragraphs.items[0].getOoxml();
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Paragraph OOXML: ' + ooxml.value);
});
getPrevious()
前の段落を取得します。 段落が最初の段落の場合は ItemNotFound エラーをスローします。
getPrevious(): Word.Paragraph;
返品
注釈
getPreviousOrNullObject()
前の段落を取得します。 段落が最初の段落の場合、このメソッドは isNullObject プロパティが true に設定されたオブジェクトを返します。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。
getPreviousOrNullObject(): Word.Paragraph;
返品
注釈
例
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the paragraphs collection.
const paragraphs = context.document.body.paragraphs;
// Queue a command to load the text property for all of the paragraphs.
paragraphs.load('text');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
// Queue commands to create a proxy object for the next-to-last paragraph.
const indexOfLastParagraph = paragraphs.items.length - 1;
const precedingParagraph = paragraphs.items[indexOfLastParagraph].getPreviousOrNullObject();
// Queue a command to load the text of the preceding paragraph.
precedingParagraph.load('text');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
if (precedingParagraph.isNullObject) {
console.log('There are no paragraphs before the current one.');
} else {
console.log('The preceding paragraph is: ' + precedingParagraph.text);
}
});
getRange(rangeLocation)
段落全体、あるいは段落の開始点または終了点を範囲として取得します。
getRange(rangeLocation?: Word.RangeLocation.whole | Word.RangeLocation.start | Word.RangeLocation.end | Word.RangeLocation.after | Word.RangeLocation.content | "Whole" | "Start" | "End" | "After" | "Content"): Word.Range;
パラメーター
- rangeLocation
-
whole | start | end | after | content | "Whole" | "Start" | "End" | "After" | "Content"
省略可能。 範囲の場所は、 whole、 start、 end、 after、または content である必要があります。
返品
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/get-paragraph-on-insertion-point.yaml
await Word.run(async (context) => {
// Get the complete sentence (as range) associated with the insertion point.
const sentences: Word.RangeCollection = context.document
.getSelection()
.getTextRanges(["."] /* Using the "." as delimiter */, false /*means without trimming spaces*/);
sentences.load("$none");
await context.sync();
// Expand the range to the end of the paragraph to get all the complete sentences.
const sentencesToTheEndOfParagraph: Word.RangeCollection = sentences.items[0]
.getRange()
.expandTo(
context.document
.getSelection()
.paragraphs.getFirst()
.getRange(Word.RangeLocation.end)
)
.getTextRanges(["."], false /* Don't trim spaces*/);
sentencesToTheEndOfParagraph.load("text");
await context.sync();
for (let i = 0; i < sentencesToTheEndOfParagraph.items.length; i++) {
console.log(sentencesToTheEndOfParagraph.items[i].text);
}
});
getReviewedText(changeTrackingVersion)
ChangeTrackingVersion選択に基づいてレビューされたテキストを取得します。
getReviewedText(changeTrackingVersion?: Word.ChangeTrackingVersion): OfficeExtension.ClientResult<string>;
パラメーター
- changeTrackingVersion
- Word.ChangeTrackingVersion
省略可能。 値は original または current にする必要があります。 既定値は current です。
返品
OfficeExtension.ClientResult<string>
注釈
getReviewedText(changeTrackingVersion)
ChangeTrackingVersion選択に基づいてレビューされたテキストを取得します。
getReviewedText(changeTrackingVersion?: "Original" | "Current"): OfficeExtension.ClientResult<string>;
パラメーター
- changeTrackingVersion
-
"Original" | "Current"
省略可能。 値は original または current にする必要があります。 既定値は current です。
返品
OfficeExtension.ClientResult<string>
注釈
getText(options)
段落のテキストを返します。 これには、数式、グラフィックス (画像、ビデオ、描画など)、およびさまざまなコンテンツをマークする特殊文字 (コンテンツ コントロール、フィールド、コメント、脚注、文末脚注など) は含まれません。 既定では、隠しテキストと削除済みとマークされたテキストは除外されます。
getText(options?: Word.GetTextOptions | {
IncludeHiddenText?: boolean;
IncludeTextMarkedAsDeleted?: boolean;
}): OfficeExtension.ClientResult<string>;
パラメーター
- options
-
Word.GetTextOptions | { IncludeHiddenText?: boolean; IncludeTextMarkedAsDeleted?: boolean; }
省略可能。 最終結果に非表示のテキストと削除済みとしてマークされたテキストを含めるかどうかを定義するオプション。
返品
OfficeExtension.ClientResult<string>
注釈
getTextRanges(endingMarks, trimSpacing)
句読点やその他の終了記号を使用して、段落内のテキスト範囲を取得します。
getTextRanges(endingMarks: string[], trimSpacing?: boolean): Word.RangeCollection;
パラメーター
- endingMarks
-
string[]
句読点とその他の終了記号は文字列の配列です。
- trimSpacing
-
boolean
省略可能。 範囲コレクションで返される範囲の開始と終了から間隔文字 (スペース、タブ、列区切り、段落終了マーク) をトリミングするかどうかを示します。 既定値は false です。これは、範囲の先頭と末尾のスペース文字が範囲コレクションに含まれることを示します。
返品
注釈
getTrackedChanges()
段落内の TrackedChange オブジェクトのコレクションを取得します。
getTrackedChanges(): Word.TrackedChangeCollection;
返品
注釈
indent()
indentCharacterWidth(count)
指定した文字数だけ段落をインデントします。
indentCharacterWidth(count: number): void;
パラメーター
- count
-
number
インデントの文字数。
返品
void
注釈
indentFirstLineCharacterWidth(count)
段落の最初の行を指定された文字数だけインデントします。
indentFirstLineCharacterWidth(count: number): void;
パラメーター
- count
-
number
1 行目のインデントの文字数。
返品
void
注釈
insertAnnotations(annotations)
この Paragraph オブジェクトに注釈を挿入します。
insertAnnotations(annotations: Word.AnnotationSet): OfficeExtension.ClientResult<string[]>;
パラメーター
- annotations
- Word.AnnotationSet
設定する注釈。
返品
OfficeExtension.ClientResult<string[]>
挿入された注釈識別子の配列。
注釈
重要: 基になるサービスの要件により、この API が正常に動作するには Microsoft 365 サブスクリプションが必要です。 詳細については、 GitHub の問題 4953 を参照してください。
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-annotations.yaml
// Adds annotations to the selected paragraph.
await Word.run(async (context) => {
const paragraph: Word.Paragraph = context.document.getSelection().paragraphs.getFirst();
const options: Word.CritiquePopupOptions = {
brandingTextResourceId: "PG.TabLabel",
subtitleResourceId: "PG.HelpCommand.TipTitle",
titleResourceId: "PG.HelpCommand.Label",
suggestions: ["suggestion 1", "suggestion 2", "suggestion 3"]
};
const critique1: Word.Critique = {
colorScheme: Word.CritiqueColorScheme.red,
start: 1,
length: 3,
popupOptions: options
};
const critique2: Word.Critique = {
colorScheme: Word.CritiqueColorScheme.green,
start: 6,
length: 1,
popupOptions: options
};
const critique3: Word.Critique = {
colorScheme: Word.CritiqueColorScheme.blue,
start: 10,
length: 3,
popupOptions: options
};
const critique4: Word.Critique = {
colorScheme: Word.CritiqueColorScheme.lavender,
start: 14,
length: 3,
popupOptions: options
};
const critique5: Word.Critique = {
colorScheme: Word.CritiqueColorScheme.berry,
start: 18,
length: 10,
popupOptions: options
};
const annotationSet: Word.AnnotationSet = {
critiques: [critique1, critique2, critique3, critique4, critique5]
};
const annotationIds = paragraph.insertAnnotations(annotationSet);
await context.sync();
console.log("Annotations inserted:", annotationIds.value);
});
insertBreak(breakType, insertLocation)
メイン文書の指定した位置に、区切りを挿入します。
insertBreak(breakType: Word.BreakType | "Page" | "Next" | "SectionNext" | "SectionContinuous" | "SectionEven" | "SectionOdd" | "Line", insertLocation: Word.InsertLocation.before | Word.InsertLocation.after | "Before" | "After"): void;
パラメーター
- breakType
-
Word.BreakType | "Page" | "Next" | "SectionNext" | "SectionContinuous" | "SectionEven" | "SectionOdd" | "Line"
文書に追加する区切りの種類。
返品
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-line-and-page-breaks.yaml
Word.run(async (context) => {
context.document.body.paragraphs.getFirst().insertBreak(Word.BreakType.line, "After");
await context.sync();
console.log("success");
});
insertCanvas(insertShapeOptions)
アンカーを段落の先頭に配置して、テキストの前にフローティング キャンバスを挿入します。
insertCanvas(insertShapeOptions?: Word.InsertShapeOptions): Word.Shape;
パラメーター
- insertShapeOptions
- Word.InsertShapeOptions
省略可能。 キャンバスの位置とサイズ。 既定の場所とサイズは (0, 0, 300, 200) です。
返品
注釈
insertContentControl(contentControlType)
Paragraph オブジェクトをコンテンツ コントロールでラップします。
insertContentControl(contentControlType?: Word.ContentControlType.richText | Word.ContentControlType.plainText | Word.ContentControlType.checkBox | Word.ContentControlType.dropDownList | Word.ContentControlType.comboBox | Word.ContentControlType.buildingBlockGallery | Word.ContentControlType.datePicker | Word.ContentControlType.repeatingSection | Word.ContentControlType.picture | Word.ContentControlType.group | "RichText" | "PlainText" | "CheckBox" | "DropDownList" | "ComboBox" | "BuildingBlockGallery" | "DatePicker" | "RepeatingSection" | "Picture" | "Group"): Word.ContentControl;
パラメーター
- contentControlType
-
richText | plainText | checkBox | dropDownList | comboBox | buildingBlockGallery | datePicker | repeatingSection | picture | group | "RichText" | "PlainText" | "CheckBox" | "DropDownList" | "ComboBox" | "BuildingBlockGallery" | "DatePicker" | "RepeatingSection" | "Picture" | "Group"
省略可能。 挿入するコンテンツ コントロールの種類。
richText
、plainText、checkBox、dropDownList、comboBox、buildingBlockGallery、datePicker、repeatingSection、picture、または group である必要があります。 既定値は richText です。
返品
注釈
注: contentControlType パラメーターは WordApi 1.5 で導入されました。
plainText サポートは WordApi 1.5 で追加されました。
checkBox サポートは WordApi 1.7 で追加されました。
dropDownList
comboBoxサポートは WordApi 1.9 で追加されました。
buildingBlockGallery
、datePicker、group、picture、repeatingSection のサポートは、WordApiDesktop 1.3 で追加されました。
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/insert-and-change-content-controls.yaml
// Traverses each paragraph of the document and wraps a content control on each with either a even or odd tags.
await Word.run(async (context) => {
let paragraphs = context.document.body.paragraphs;
paragraphs.load("$none"); // Don't need any properties; just wrap each paragraph with a content control.
await context.sync();
for (let i = 0; i < paragraphs.items.length; i++) {
let contentControl = paragraphs.items[i].insertContentControl();
// For even, tag "even".
if (i % 2 === 0) {
contentControl.tag = "even";
} else {
contentControl.tag = "odd";
}
}
console.log("Content controls inserted: " + paragraphs.items.length);
await context.sync();
});
insertFileFromBase64(base64File, insertLocation)
指定した位置にある段落にドキュメントを挿入します。
insertFileFromBase64(base64File: string, insertLocation: Word.InsertLocation.replace | Word.InsertLocation.start | Word.InsertLocation.end | "Replace" | "Start" | "End"): Word.Range;
パラメーター
- base64File
-
string
.docx ファイルの Base64 でエンコードされたコンテンツ。
値は、 replace、 start、または end である必要があります。
返品
注釈
挿入するドキュメントに ActiveX コントロール (フォーム フィールドにある可能性があります) が含まれている場合、挿入はサポートされません。 このようなフォーム フィールドを、シナリオに適したコンテンツ コントロールまたはその他のオプションに置き換えることを検討してください。
insertGeometricShape(geometricShapeType, insertShapeOptions)
テキストの前に幾何学図形を挿入し、アンカーを段落の先頭に配置します。
insertGeometricShape(geometricShapeType: Word.GeometricShapeType, insertShapeOptions?: Word.InsertShapeOptions): Word.Shape;
パラメーター
- geometricShapeType
- Word.GeometricShapeType
挿入する図形の幾何学的タイプ。
- insertShapeOptions
- Word.InsertShapeOptions
省略可能。 幾何学的図形の位置とサイズ。 既定の場所とサイズは (0, 0, 100, 100) です。
返品
注釈
例
// 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) => {
const body: Word.Body = context.document.body;
body.clear();
const lastParagraph: Word.Paragraph = body.paragraphs.getLast();
// Inserts a text box.
const textBoxOptions: Word.InsertShapeOptions = {
top: 0,
left: 0,
height: 100,
width: 100,
};
lastParagraph.insertTextBox("placeholder text", textBoxOptions);
// Inserts a geometric shape.
const geometricShapeOptions: Word.InsertShapeOptions = {
height: 120,
width: 120,
left: 120,
};
lastParagraph.insertGeometricShape(Word.GeometricShapeType.star24, geometricShapeOptions);
// Inserts a picture.
const pictureOptions: Word.InsertShapeOptions = {
top: 120,
left: 60,
height: 150,
width: 150,
};
lastParagraph.insertPictureFromBase64(getPictureBase64(), pictureOptions);
await context.sync();
});
insertGeometricShape(geometricShapeType, insertShapeOptions)
テキストの前に幾何学図形を挿入し、アンカーを段落の先頭に配置します。
insertGeometricShape(geometricShapeType: "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus", insertShapeOptions?: Word.InsertShapeOptions): Word.Shape;
パラメーター
- geometricShapeType
-
"LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus"
挿入する図形の幾何学的タイプ。
- insertShapeOptions
- Word.InsertShapeOptions
省略可能。 幾何学的図形の位置とサイズ。 既定の場所とサイズは (0, 0, 100, 100) です。
返品
注釈
insertHtml(html, insertLocation)
段落の指定した位置に、HTML を挿入します。
insertHtml(html: string, insertLocation: Word.InsertLocation.replace | Word.InsertLocation.start | Word.InsertLocation.end | "Replace" | "Start" | "End"): Word.Range;
パラメーター
- html
-
string
段落に挿入する HTML。
値は、 replace、 start、または end である必要があります。
返品
注釈
例
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the paragraphs collection.
const paragraphs = context.document.body.paragraphs;
// Queue a command to load the style property for the top 2 paragraphs.
// We never perform an empty load. We always must request a property.
paragraphs.load({select: 'style', top: 2} );
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
// Queue a command to get the first paragraph.
const paragraph = paragraphs.items[0];
// Queue a command to insert HTML content at the end of the first paragraph.
paragraph.insertHtml('<strong>Inserted HTML.</strong>', Word.InsertLocation.end);
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Inserted HTML content at the end of the first paragraph.');
});
insertInlinePictureFromBase64(base64EncodedImage, insertLocation)
段落の指定した位置に、図を挿入します。
insertInlinePictureFromBase64(base64EncodedImage: string, insertLocation: Word.InsertLocation.replace | Word.InsertLocation.start | Word.InsertLocation.end | "Replace" | "Start" | "End"): Word.InlinePicture;
パラメーター
- base64EncodedImage
-
string
挿入する Base64 でエンコードされた画像。
値は、 replace、 start、または end である必要があります。
返品
注釈
例
// Run a batch operation against the Word object model.
await Word.run(async (context) => {
// Create a proxy object for the paragraphs collection.
const paragraphs = context.document.body.paragraphs;
// Queue a command to load the style property for all of the paragraphs.
paragraphs.load('style');
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
// Queue a command to get the first paragraph.
const paragraph = paragraphs.items[0];
const b64encodedImg = "iVBORw0KGgoAAAANSUhEUgAAAB4AAAANCAIAAAAxEEnAAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACFSURBVDhPtY1BEoQwDMP6/0+XgIMTBAeYoTqso9Rkx1zG+tNj1H94jgGzeNSjteO5vtQQuG2seO0av8LzGbe3anzRoJ4ybm/VeKEerAEbAUpW4aWQCmrGFWykRzGBCnYy2ha3oAIq2MloW9yCCqhgJ6NtcQsqoIKdjLbFLaiACnYyf2fODbrjZcXfr2F4AAAAAElFTkSuQmCC";
// Queue a command to insert a base64 encoded image at the beginning of the first paragraph.
paragraph.insertInlinePictureFromBase64(b64encodedImg, Word.InsertLocation.start);
// Synchronize the document state by executing the queued commands,
// and return a promise to indicate task completion.
await context.sync();
console.log('Added an image to the first paragraph.');
});
insertOoxml(ooxml, insertLocation)
指定した位置の段落に OOXML を挿入します。
insertOoxml(ooxml: string, insertLocation: Word.InsertLocation.replace | Word.InsertLocation.start | Word.InsertLocation.end | "Replace" | "Start" | "End"): Word.Range;
パラメーター
- ooxml
-
string
段落に挿入される OOXML。
値は、 replace、 start、または end である必要があります。
返品
注釈
insertParagraph(paragraphText, insertLocation)
指定した位置に、段落を挿入します。
insertParagraph(paragraphText: string, insertLocation: Word.InsertLocation.before | Word.InsertLocation.after | "Before" | "After"): Word.Paragraph;
パラメーター
- paragraphText
-
string
挿入する段落テキスト。
返品
注釈
insertPictureFromBase64(base64EncodedImage, insertShapeOptions)
アンカーを段落の先頭に配置して、テキストの前に浮動画像を挿入します。
insertPictureFromBase64(base64EncodedImage: string, insertShapeOptions?: Word.InsertShapeOptions): Word.Shape;
パラメーター
- base64EncodedImage
-
string
挿入する Base64 でエンコードされた画像。
- insertShapeOptions
- Word.InsertShapeOptions
省略可能。 画像の場所とサイズ。 既定の場所は (0, 0) で、既定のサイズは画像の元のサイズです。
返品
注釈
insertTable(rowCount, columnCount, insertLocation, values)
指定した数の行と列を含むテーブルを挿入します。
insertTable(rowCount: number, columnCount: number, insertLocation: Word.InsertLocation.before | Word.InsertLocation.after | "Before" | "After", values?: string[][]): Word.Table;
パラメーター
- rowCount
-
number
表の行数を指定します。
- columnCount
-
number
表の列数を指定します。
- values
-
string[][]
省略可能な 2 次元配列。 対応する文字列が配列で指定されている場合、セルに設定されます。
返品
注釈
insertText(text, insertLocation)
段落の指定した位置に、テキストを挿入します。
insertText(text: string, insertLocation: Word.InsertLocation.replace | Word.InsertLocation.start | Word.InsertLocation.end | "Replace" | "Start" | "End"): Word.Range;
パラメーター
- text
-
string
挿入するテキスト。
値は、 replace、 start、または end である必要があります。
返品
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/25-paragraph/insert-in-different-locations.yaml
await Word.run(async (context) => {
// Replace the last paragraph.
const range: Word.Range = context.document.body.paragraphs.getLast().insertText("Just replaced the last paragraph!", "Replace");
range.font.highlightColor = "black";
range.font.color = "white";
await context.sync();
});
insertTextBox(text, insertShapeOptions)
テキストの前にフローティング テキスト ボックスを挿入し、アンカーを段落の先頭に配置します。
insertTextBox(text?: string, insertShapeOptions?: Word.InsertShapeOptions): Word.Shape;
パラメーター
- text
-
string
省略可能。 テキスト ボックスに挿入するテキスト。
- insertShapeOptions
- Word.InsertShapeOptions
省略可能。 テキスト ボックスの場所とサイズ。 既定の場所とサイズは (0, 0, 100, 100) です。
返品
注釈
例
// 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 first paragraph in the header.
const headerFooterBody: Word.Body = context.document.sections.getFirst().getHeader(Word.HeaderFooterType.primary);
headerFooterBody.load("paragraphs");
const firstParagraph: Word.Paragraph = headerFooterBody.paragraphs.getFirst();
const insertShapeOptions: Word.InsertShapeOptions = {
top: 0,
left: 0,
height: 100,
width: 100
};
const newTextBox: Word.Shape = firstParagraph.insertTextBox("placeholder text", insertShapeOptions);
newTextBox.select();
await context.sync();
console.log("Inserted a text box at the beginning of the first paragraph in the header.");
});
joinList()
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Word.Interfaces.ParagraphLoadOptions): Word.Paragraph;
パラメーター
読み込むオブジェクトのプロパティのオプションを指定します。
返品
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): Word.Paragraph;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。
返品
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Word.Paragraph;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。
返品
next(count)
次の段落を示す Paragraph オブジェクトを返します。
next(count: number): Word.Paragraph;
パラメーター
- count
-
number
省略可能。 先に進む段落数。
返品
注釈
openOrCloseUp()
openUp()
outdent()
outlineDemote()
次の見出しレベル スタイル (見出し 1 から見出し 8) を段落に適用します。
outlineDemote(): void;
返品
void
注釈
outlineDemoteToBody()
outlinePromote()
前の見出しレベル スタイル (見出し 1 から見出し 8) を段落に適用します。
outlinePromote(): void;
返品
void
注釈
previous(count)
前の段落を Paragraph オブジェクトとして返します。
previous(count: number): Word.Paragraph;
パラメーター
- count
-
number
省略可能。 後方に移動する段落の数。
返品
注釈
reset()
resetAdvanceTo()
search(searchText, searchOptions)
Paragraph オブジェクトのスコープに対して、指定された検索オプションを使用して検索を実行します。 検索結果は、 Range オブジェクトのコレクションです。
search(searchText: string, searchOptions?: Word.SearchOptions | {
ignorePunct?: boolean;
ignoreSpace?: boolean;
matchCase?: boolean;
matchPrefix?: boolean;
matchSuffix?: boolean;
matchWholeWord?: boolean;
matchWildcards?: boolean;
}): Word.RangeCollection;
パラメーター
- searchText
-
string
検索テキスト。
- searchOptions
-
Word.SearchOptions | { ignorePunct?: boolean; ignoreSpace?: boolean; matchCase?: boolean; matchPrefix?: boolean; matchSuffix?: boolean; matchWholeWord?: boolean; matchWildcards?: boolean; }
省略可能。 検索のオプション。
返品
注釈
select(selectionMode)
段落を選択して、その段落に Word の UI を移動します。
select(selectionMode?: Word.SelectionMode): void;
パラメーター
- selectionMode
- Word.SelectionMode
省略可能。 選択モードは、 select、 start、または end である必要があります。
select が既定です。
返品
void
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/scroll-to-range.yaml
await Word.run(async (context) => {
// If select is called with no parameters, it selects the object.
context.document.body.paragraphs.getLast().select();
await context.sync();
});
...
await Word.run(async (context) => {
// Select can be at the start or end of a range; this by definition moves the insertion point without selecting the range.
context.document.body.paragraphs.getLast().select(Word.SelectionMode.end);
await context.sync();
});
select(selectionMode)
段落を選択して、その段落に Word の UI を移動します。
select(selectionMode?: "Select" | "Start" | "End"): void;
パラメーター
- selectionMode
-
"Select" | "Start" | "End"
省略可能。 選択モードは、 select、 start、または end である必要があります。
select が既定です。
返品
void
注釈
selectNumber()
separateList()
1 つのリストを 2 つのリストに分割します。 段落番号の場合、新しいリストは開始番号 (通常 1) から番号付けが再開されます。
separateList(): void;
返品
void
注釈
set(properties, options)
オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクト、または同じ型の別の API オブジェクトを渡すことができます。
set(properties: Interfaces.ParagraphUpdateData, options?: OfficeExtension.UpdateOptions): void;
パラメーター
- properties
- Word.Interfaces.ParagraphUpdateData
メソッドが呼び出されたオブジェクトのプロパティと同型構造のプロパティを持つ JavaScript オブジェクト。
- options
- OfficeExtension.UpdateOptions
プロパティ オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。
返品
void
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/90-scenarios/multiple-property-set.yaml
await Word.run(async (context) => {
const paragraph: Word.Paragraph = context.document.body.paragraphs.getFirst();
paragraph.set({
leftIndent: 30,
font: {
bold: true,
color: "red"
}
});
await context.sync();
});
...
await Word.run(async (context) => {
const firstParagraph: Word.Paragraph = context.document.body.paragraphs.getFirst();
const secondParagraph: Word.Paragraph = firstParagraph.getNext();
firstParagraph.load("text, font/color, font/bold, leftIndent");
await context.sync();
secondParagraph.set(firstParagraph);
await context.sync();
});
set(properties)
既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。
set(properties: Word.Paragraph): void;
パラメーター
- properties
- Word.Paragraph
返品
void
space1()
space1Pt5()
space2()
split(delimiters, trimDelimiters, trimSpacing)
区切り記号を使用して、段落を子の範囲に分割します。
split(delimiters: string[], trimDelimiters?: boolean, trimSpacing?: boolean): Word.RangeCollection;
パラメーター
- delimiters
-
string[]
区切り記号。文字列の配列です。
- trimDelimiters
-
boolean
省略可能。 範囲コレクション内の範囲から区切り記号をトリミングするかどうかを示します。 既定値は false です。これは、区切り記号が範囲コレクションで返される範囲に含まれることを示します。
- trimSpacing
-
boolean
省略可能。 範囲コレクションで返される範囲の開始と終了から間隔文字 (スペース、タブ、列区切り、段落終了マーク) をトリミングするかどうかを示します。 既定値は false です。これは、範囲の先頭と末尾のスペース文字が範囲コレクションに含まれることを示します。
返品
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/35-ranges/split-words-of-first-paragraph.yaml
await Word.run(async (context) => {
const paragraph: Word.Paragraph = context.document.body.paragraphs.getFirst();
const words = paragraph.split([" "], true /* trimDelimiters*/, true /* trimSpaces */);
words.load("text");
await context.sync();
for (let i = 0; i < words.items.length; i++) {
if (i >= 1) {
words.items[i - 1].font.highlightColor = "#FFFFFF";
}
words.items[i].font.highlightColor = "#FFFF00";
await context.sync();
await pause(200);
}
});
startNewList()
この段落を含む新しいリストを開始します。 段落が既にリスト アイテムである場合は失敗します。
startNewList(): Word.List;
返品
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/insert-list.yaml
// This example starts a new list with the second paragraph.
await Word.run(async (context) => {
const paragraphs: Word.ParagraphCollection = context.document.body.paragraphs;
paragraphs.load("$none");
await context.sync();
// Start new list using the second paragraph.
const list: Word.List = paragraphs.items[1].startNewList();
list.load("$none");
await context.sync();
// To add new items to the list, use Start or End on the insertLocation parameter.
list.insertParagraph("New list item at the start of the list", "Start");
const paragraph: Word.Paragraph = list.insertParagraph("New list item at the end of the list (set to list level 5)", "End");
// Set up list level for the list item.
paragraph.listItem.level = 4;
// To add paragraphs outside the list, use Before or After.
list.insertParagraph("New paragraph goes after (not part of the list)", "After");
await context.sync();
});
tabHangingIndent(count)
指定されたタブ位置にぶら下げインデントを設定します。
tabHangingIndent(count: number): void;
パラメーター
- count
-
number
ぶら下げているインデントのタブ位置の数。
返品
void
注釈
tabIndent(count)
段落の左インデントを、指定したタブ位置の数に設定します。
tabIndent(count: number): void;
パラメーター
- count
-
number
左インデントのタブ位置の数。
返品
void
注釈
toJSON()
API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の Word.Paragraph オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Word.Interfaces.ParagraphData と型指定) を返します。
toJSON(): Word.Interfaces.ParagraphData;
返品
track()
ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject) の短縮形です。 このオブジェクトを .sync 呼び出しと ".run" バッチの連続実行の外部で使用していて、プロパティを設定したり、オブジェクトでメソッドを呼び出したりするときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。 このオブジェクトがコレクションの一部である場合は、親コレクションも追跡する必要があります。
track(): Word.Paragraph;
返品
untrack()
前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、 context.trackedObjects.remove(thisObject) の省略形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ リリースを有効にする前に、 context.sync() を呼び出す必要があります。
untrack(): Word.Paragraph;
返品
イベントの詳細
onCommentAdded
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
新しいコメントが追加されたときに発生します。
readonly onCommentAdded: OfficeExtension.EventHandlers<Word.CommentEventArgs>;
イベントの種類
注釈
onCommentChanged
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
コメントまたはその応答が変更されたときに発生します。
readonly onCommentChanged: OfficeExtension.EventHandlers<Word.CommentEventArgs>;
イベントの種類
注釈
onCommentDeleted
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
コメントが削除されたときに発生します。
readonly onCommentDeleted: OfficeExtension.EventHandlers<Word.CommentEventArgs>;
イベントの種類
注釈
onCommentDeselected
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
コメントの選択が解除されたときに発生します。
readonly onCommentDeselected: OfficeExtension.EventHandlers<Word.CommentEventArgs>;
イベントの種類
注釈
onCommentSelected
注意
この API は開発者向けにプレビューとして提供されており、寄せられたフィードバックにもとづいて変更される場合があります。 この API は運用環境で使用しないでください。
コメントが選択されているときに発生します。
readonly onCommentSelected: OfficeExtension.EventHandlers<Word.CommentEventArgs>;