Word.TextFrame class
Wordのテキスト フレームを表します。Shape オブジェクト。
- Extends
注釈
[ API set: WordApiDesktop 1.2 ]
例
// 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) => {
// Gets the text frame of the first text box in the main document.
const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject();
shape.load("textFrame");
await context.sync();
if (shape.isNullObject) {
console.log("No shapes with text boxes found in the main document.");
return;
}
console.log("Text frame of first text box:", shape.textFrame);
});
プロパティ
| auto |
テキスト フレームの自動サイズ設定を指定します。 テキストをテキスト フレームに自動的に合わせる、テキスト フレームをテキストに自動的に合わせる、自動サイズ変更を行わない、のいずれかにテキスト フレームを設定できます。 |
| bottom |
テキスト フレームの下余白をポイント単位で指定します。 |
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| has |
テキスト フレームにテキストが含まれている場合は |
| left |
テキスト フレームの左余白をポイント単位で指定します。 |
| no |
図形の回転時にテキスト フレーム内のテキストを回転させてはいけないかどうかを指定します。 |
| orientation | テキストフレームのテキストの向きを指定します。 詳細は「 |
| right |
テキスト フレームの右余白をポイント単位で指定します。 |
| top |
テキスト フレームの上余白をポイント単位で指定します。 |
| vertical |
テキスト フレームの垂直方向の配置を指定します。 詳細は「 |
| word |
図形内のテキストに合わせて自動的に改行するかどうかを指定します。 |
メソッド
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| set(properties, options) | オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。 |
| set(properties) | 既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。 |
| toJSON() | API オブジェクトが |
| track() | ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject)の短縮形です。 このオブジェクトを |
| untrack() | 前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは 、context.trackedObjects.remove(thisObject)の短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に、 |
プロパティの詳細
autoSizeSetting
テキスト フレームの自動サイズ設定を指定します。 テキストをテキスト フレームに自動的に合わせる、テキスト フレームをテキストに自動的に合わせる、自動サイズ変更を行わない、のいずれかにテキスト フレームを設定できます。
autoSizeSetting: Word.ShapeAutoSize | "None" | "TextToFitShape" | "ShapeToFitText" | "Mixed";
プロパティ値
Word.ShapeAutoSize | "None" | "TextToFitShape" | "ShapeToFitText" | "Mixed"
注釈
[ API set: WordApiDesktop 1.2 ]
例
// 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) => {
// Sets text frame properties of the first text box in the main document.
const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject();
shape.load("textFrame");
await context.sync();
if (shape.isNullObject) {
console.log("No shapes with text boxes found in the main document.");
return;
}
const textFrame: Word.TextFrame = shape.textFrame;
textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom;
textFrame.orientation = Word.ShapeTextOrientation.vertical270;
textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText;
console.log("The first text box's text frame properties were updated:", textFrame);
});
bottomMargin
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
hasText
テキスト フレームにテキストが含まれている場合は true を返します。それ以外の場合は、 false。
readonly hasText: boolean;
プロパティ値
boolean
注釈
leftMargin
noTextRotation
図形の回転時にテキスト フレーム内のテキストを回転させてはいけないかどうかを指定します。
noTextRotation: boolean;
プロパティ値
boolean
注釈
orientation
テキストフレームのテキストの向きを指定します。 詳細は「Word.ShapeTextOrientation」をご覧ください。
orientation: Word.ShapeTextOrientation | "None" | "Horizontal" | "EastAsianVertical" | "Vertical270" | "Vertical" | "EastAsianHorizontalRotated" | "Mixed";
プロパティ値
Word.ShapeTextOrientation | "None" | "Horizontal" | "EastAsianVertical" | "Vertical270" | "Vertical" | "EastAsianHorizontalRotated" | "Mixed"
注釈
[ API set: WordApiDesktop 1.2 ]
例
// 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) => {
// Sets text frame properties of the first text box in the main document.
const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject();
shape.load("textFrame");
await context.sync();
if (shape.isNullObject) {
console.log("No shapes with text boxes found in the main document.");
return;
}
const textFrame: Word.TextFrame = shape.textFrame;
textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom;
textFrame.orientation = Word.ShapeTextOrientation.vertical270;
textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText;
console.log("The first text box's text frame properties were updated:", textFrame);
});
rightMargin
topMargin
verticalAlignment
テキスト フレームの垂直方向の配置を指定します。 詳細は「Word.ShapeTextVerticalAlignment」をご覧ください。
verticalAlignment: Word.ShapeTextVerticalAlignment | "Top" | "Middle" | "Bottom";
プロパティ値
Word.ShapeTextVerticalAlignment | "Top" | "Middle" | "Bottom"
注釈
[ API set: WordApiDesktop 1.2 ]
例
// 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) => {
// Sets text frame properties of the first text box in the main document.
const shape: Word.Shape = context.document.body.shapes.getByTypes([Word.ShapeType.textBox]).getFirstOrNullObject();
shape.load("textFrame");
await context.sync();
if (shape.isNullObject) {
console.log("No shapes with text boxes found in the main document.");
return;
}
const textFrame: Word.TextFrame = shape.textFrame;
textFrame.verticalAlignment = Word.ShapeTextVerticalAlignment.bottom;
textFrame.orientation = Word.ShapeTextOrientation.vertical270;
textFrame.autoSizeSetting = Word.ShapeAutoSize.shapeToFitText;
console.log("The first text box's text frame properties were updated:", textFrame);
});
wordWrap
図形内のテキストに合わせて自動的に改行するかどうかを指定します。
wordWrap: boolean;
プロパティ値
boolean
注釈
メソッドの詳細
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Word.Interfaces.TextFrameLoadOptions): Word.TextFrame;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): Word.TextFrame;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Word.TextFrame;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列で、 propertyNamesAndPaths.expand は読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
set(properties, options)
オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクトまたは同じ型の別の API オブジェクトを渡すことができます。
set(properties: Interfaces.TextFrameUpdateData, options?: OfficeExtension.UpdateOptions): void;
パラメーター
- properties
- Word.Interfaces.TextFrameUpdateData
メソッドが呼び出されるオブジェクトのプロパティに等形的に構造化されたプロパティを持つ JavaScript オブジェクト。
- options
- OfficeExtension.UpdateOptions
properties オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。
戻り値
void
set(properties)
既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。
set(properties: Word.TextFrame): void;
パラメーター
- properties
- Word.TextFrame
戻り値
void
toJSON()
API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の Word.TextFrame オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Word.Interfaces.TextFrameData として型指定) を返します。
toJSON(): Word.Interfaces.TextFrameData;
戻り値
track()
ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject)の短縮形です。 このオブジェクトを .sync 呼び出しで使用し、".run" バッチのシーケンシャル実行の外部でプロパティを設定するとき、またはオブジェクトに対してメソッドを呼び出すときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。 このオブジェクトがコレクションの一部である場合は、親コレクションも追跡する必要があります。
track(): Word.TextFrame;
戻り値
untrack()
前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは 、context.trackedObjects.remove(thisObject)の短縮形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ解放が有効になる前に、 context.sync() を呼び出す必要があります。
untrack(): Word.TextFrame;