このトピックでは、テキストドキュメントの Section オブジェクトに関連する API 操作について説明します。
セクション
ActiveDocument.Sections
ドキュメント内のすべてのセクションを取得します。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections
expression: ドキュメント タイプ アプリケーション オブジェクト。
例
async function example() { await instance.ready(); const app = instance.Application; // すべてのセクションを取得します。 const Sections = await app.ActiveDocument.Sections; }
プロパティ
ActiveDocument.Sections.Count
Count
プロパティを使用して、セクションの総数を取得できます。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections.Count
expression: ドキュメント タイプ アプリケーション オブジェクト。
例
async function example() { await instance.ready(); const app = instance.Application; // すべてのセクションを取得します。 const Sections = await app.ActiveDocument.Sections; // ドキュメント内のセクションの総数を取得します。 const count = await Sections.Count; console.log(count); }
セクション
ActiveDocument.Sections.Item(Index)
単一の Section オブジェクトを取得します。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections.Item(Index)
expression: ドキュメント タイプ アプリケーション オブジェクト。
例
async function example() { await instance.ready(); const app = instance.Application; // 単一の Section オブジェクトを取得します。 const Section = await app.ActiveDocument.Sections.Item(Index); }
メソッド
ActiveDocument.Sections.Item(Index).PageSetup.TypesetToPage(PageNum)
テキストドキュメントは動的なレイアウトを使用します。TypesetToPage()
メソッドを使用して、読み込むページ数を指定できます。その他のページは、ドキュメントがスクロールされると読み込まれます。
構文
expression.ActiveDocument.Sections.Item(Index).PageSetup.TypesetToPage(PageNum)
expression: ドキュメント タイプ アプリケーション オブジェクト。
パラメータ
プロパティ
タイプ
必須
説明
PageNum
数値
はい
読み込むページ数。
例
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // PageSetup オブジェクトを取得します。 const pageSetup = await app.ActiveDocument.Sections.Item(1).PageSetup; // 指定されたページまでタイプセットします。 await pageSetup.TypesetToPage(2); }
プロパティ
ActiveDocument.Sections.Item(Index).PageSetup
PageSetup
プロパティを使用して、単一セクションのページ設定を取得できます。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections.Item(Index).PageSetup
expression: ドキュメント タイプ アプリケーション オブジェクト。
例
async function example() { await instance.ready(); const app = instance.Application; // 最初のセクションのページ設定を取得します。 const Section = await app.ActiveDocument.Sections.Item(1).PageSetup; }
ActiveDocument.Sections.Item(Index).PageSetup.PageWidth
PageWidth
プロパティを使用して、ページの幅を取得できます。
構文
expression.ActiveDocument.Sections.Item(Index).PageSetup.PageWidth
expression: ドキュメント タイプ アプリケーション オブジェクト。
例
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // PageSetup オブジェクトを取得します。 const PageSetup = await app.ActiveDocument.Sections.Item(1).PageSetup; // ページの幅を取得します。 const pageWidth = await PageSetup.PageWidth; console.log(pageWidth); }
ActiveDocument.Sections.Item(Index).WaterMarks
WaterMarks
プロパティを使用して、単一セクションのウォーターマークを取得できます。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections.Item(Index).WaterMarks
expression: ドキュメント タイプ アプリケーション オブジェクト。
例
async function example() { await instance.ready(); const app = instance.Application; // 最初のセクションのウォーターマークを取得します。 const Section = await app.ActiveDocument.Sections.Item(1).WaterMarks; }
HeadersFooters
ActiveDocument.Sections.Item(Index).Headers
単一の Section オブジェクト内のすべてのヘッダーを取得します。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections.Item(Index).Headers
expression: ドキュメント タイプ アプリケーション オブジェクト。
パラメータ
プロパティ
タイプ
必須
説明
Type
列挙型
はい
返すヘッダーのタイプを指定します。詳細については、「WdHeaderFooterIndex」をご参照ください。
戻り値
HeadersFooters
オブジェクトを返します。例
async function example() { await instance.ready(); const app = instance.Application; // 単一の Section オブジェクト内のすべてのヘッダーを取得します。 const Headers = await app.ActiveDocument.Sections.Item(Index).Headers; }
ActiveDocument.Sections.Item(Index).Footers
単一の Section オブジェクト内のすべてのフッターを取得します。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections.Item(Index).Footers
expression: ドキュメント タイプ アプリケーション オブジェクト。
パラメータ
プロパティ
タイプ
必須
説明
Type
列挙型
はい
返すフッターのタイプを指定します。詳細については、「WdHeaderFooterIndex」をご参照ください。
戻り値
HeadersFooters
オブジェクトを返します。例
async function example() { await instance.ready(); const app = instance.Application; // 単一の Section オブジェクト内のすべてのフッターを取得します。 const Headers = await app.ActiveDocument.Sections.Item(Index).Footers; }
プロパティ
ActiveDocument.Sections.Item(Index).Headers.Range
Range
プロパティを使用して、単一のヘッダー内に含まれるドキュメントの部分を取得できます。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections.Item(Index).Headers.Range
expression: ドキュメント タイプ アプリケーション オブジェクト。
例
async function example() { await instance.ready(); const app = instance.Application; // 単一のヘッダー内に含まれるドキュメントの部分を取得します。 const Range = await app.ActiveDocument.Sections.Item(1).Headers.Range; }
ActiveDocument.Sections.Item(Index).Footers.Range
Range
プロパティを使用して、単一のフッター内に含まれるドキュメントの部分を取得できます。
JS-SDK V1.1.10 以降でのみ、この機能がサポートされています。
構文
expression.ActiveDocument.Sections.Item(Index).Footers.Range
expression: ドキュメント タイプ アプリケーション オブジェクト。
例
async function example() { await instance.ready(); const app = instance.Application; // 単一のフッター内に含まれるドキュメントの部分を取得します。 const Range = await app.ActiveDocument.Sections.Item(1).Footers.Range; }