PowerPoint.Shape class
スライド内の 1 つの図形を表します。
- Extends
注釈
[ API セット: PowerPointApi 1.3 ]
プロパティ
context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
fill | この図形の塗りつぶしの書式設定を返します。 |
height | 図形の高さをポイント単位で指定します。 負の値を |
id | 図形の一意の ID を取得します。 |
left | 図形の左側からスライドの左側までの距離をポイント単位で指定します。 |
line |
この図形の線の書式設定を返します。 |
name | この図形の名前を指定します。 |
tags | 図形内のタグのコレクションを返します。 |
text |
この図形のテキスト フレーム オブジェクトを返します。 |
top | 図形の上端からスライドの上端までの距離をポイント単位で指定します。 |
type | この図形の種類を返します。 詳細については、「 PowerPoint.ShapeType 」を参照してください。 |
width | 図形の幅をポイント単位で指定します。 負の値を |
メソッド
delete() | 図形コレクションから図形を削除します。 図形が存在しない場合は何も行いません。 |
get |
この |
get |
この |
get |
この |
get |
この |
get |
この |
get |
この |
load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
toJSON() | API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
fill
この図形の塗りつぶしの書式設定を返します。
readonly fill: PowerPoint.ShapeFill;
プロパティ値
注釈
[ API セット: PowerPointApi 1.4 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml
// Changes the selected shapes fill color to red.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
shapes.load("items");
await context.sync();
shapes.items.map((shape) => {
shape.fill.setSolidColor("red");
});
await context.sync();
});
height
図形の高さをポイント単位で指定します。 負の値を InvalidArgument
設定すると例外がスローされます。
height: number;
プロパティ値
number
注釈
[ API セット: PowerPointApi 1.4 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml
// Arranges the selected shapes in a line from left to right.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
shapes.load("items");
await context.sync();
let maxHeight = 0;
shapes.items.map((shape) => {
shape.load("width,height");
});
await context.sync();
shapes.items.map((shape) => {
shape.left = currentLeft;
shape.top = currentTop;
currentLeft += shape.width;
if (shape.height > maxHeight) maxHeight = shape.height;
});
await context.sync();
currentLeft = 0;
if (currentTop > slideHeight - 200) currentTop = 0;
});
id
left
図形の左側からスライドの左側までの距離をポイント単位で指定します。
left: number;
プロパティ値
number
注釈
[ API セット: PowerPointApi 1.4 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml
// Arranges the selected shapes in a line from left to right.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
shapes.load("items");
await context.sync();
let maxHeight = 0;
shapes.items.map((shape) => {
shape.load("width,height");
});
await context.sync();
shapes.items.map((shape) => {
shape.left = currentLeft;
shape.top = currentTop;
currentLeft += shape.width;
if (shape.height > maxHeight) maxHeight = shape.height;
});
await context.sync();
currentLeft = 0;
if (currentTop > slideHeight - 200) currentTop = 0;
});
lineFormat
この図形の線の書式設定を返します。
readonly lineFormat: PowerPoint.ShapeLineFormat;
プロパティ値
注釈
name
tags
図形内のタグのコレクションを返します。
readonly tags: PowerPoint.TagCollection;
プロパティ値
注釈
textFrame
この図形のテキスト フレーム オブジェクトを返します。
readonly textFrame: PowerPoint.TextFrame;
プロパティ値
注釈
top
図形の上端からスライドの上端までの距離をポイント単位で指定します。
top: number;
プロパティ値
number
注釈
[ API セット: PowerPointApi 1.4 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml
// Arranges the selected shapes in a line from left to right.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
shapes.load("items");
await context.sync();
let maxHeight = 0;
shapes.items.map((shape) => {
shape.load("width,height");
});
await context.sync();
shapes.items.map((shape) => {
shape.left = currentLeft;
shape.top = currentTop;
currentLeft += shape.width;
if (shape.height > maxHeight) maxHeight = shape.height;
});
await context.sync();
currentLeft = 0;
if (currentTop > slideHeight - 200) currentTop = 0;
});
type
この図形の種類を返します。 詳細については、「 PowerPoint.ShapeType 」を参照してください。
readonly type: PowerPoint.ShapeType | "Unsupported" | "Image" | "GeometricShape" | "Group" | "Line" | "Table";
プロパティ値
PowerPoint.ShapeType | "Unsupported" | "Image" | "GeometricShape" | "Group" | "Line" | "Table"
注釈
width
図形の幅をポイント単位で指定します。 負の値を InvalidArgument
設定すると例外がスローされます。
width: number;
プロパティ値
number
注釈
[ API セット: PowerPointApi 1.4 ]
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-set-shapes.yaml
// Arranges the selected shapes in a line from left to right.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
shapes.load("items");
await context.sync();
let maxHeight = 0;
shapes.items.map((shape) => {
shape.load("width,height");
});
await context.sync();
shapes.items.map((shape) => {
shape.left = currentLeft;
shape.top = currentTop;
currentLeft += shape.width;
if (shape.height > maxHeight) maxHeight = shape.height;
});
await context.sync();
currentLeft = 0;
if (currentTop > slideHeight - 200) currentTop = 0;
});
メソッドの詳細
delete()
getParentSlide()
この Shape
を保持する親 PowerPoint.Slide オブジェクトを返します。 この図形が に属していない場合は、例外を Slide
スローします。
getParentSlide(): PowerPoint.Slide;
戻り値
注釈
getParentSlideLayout()
この Shape
を保持する親 PowerPoint.SlideLayout オブジェクトを返します。 この図形が に属していない場合は、例外を SlideLayout
スローします。
getParentSlideLayout(): PowerPoint.SlideLayout;
戻り値
注釈
getParentSlideLayoutOrNullObject()
この Shape
を保持する親 PowerPoint.SlideLayout オブジェクトを返します。 この図形が にSlideLayout
属していない場合は、 プロパティが にtrue
設定されたオブジェクトisNullObject
が返されます。
getParentSlideLayoutOrNullObject(): PowerPoint.SlideLayout;
戻り値
注釈
getParentSlideMaster()
この Shape
を保持する親 PowerPoint.SlideMaster オブジェクトを返します。 この図形が に属していない場合は、例外を SlideMaster
スローします。
getParentSlideMaster(): PowerPoint.SlideMaster;
戻り値
注釈
getParentSlideMasterOrNullObject()
この Shape
を保持する親 PowerPoint.SlideMaster オブジェクトを返します。 この図形が にSlideMaster
属していない場合は、 プロパティが にtrue
設定されたオブジェクトisNullObject
が返されます。
getParentSlideMasterOrNullObject(): PowerPoint.SlideMaster;
戻り値
注釈
getParentSlideOrNullObject()
この Shape
を保持する親 PowerPoint.Slide オブジェクトを返します。 この図形が にSlide
属していない場合は、 プロパティが にtrue
設定されたオブジェクトisNullObject
が返されます。
getParentSlideOrNullObject(): PowerPoint.Slide;
戻り値
注釈
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(options?: PowerPoint.Interfaces.ShapeLoadOptions): PowerPoint.Shape;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(propertyNames?: string | string[]): PowerPoint.Shape;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): PowerPoint.Shape;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select
は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand
、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
toJSON()
API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON()
メソッドを JSON.stringify()
オーバーライドします。 (JSON.stringify
さらに、渡される オブジェクトの メソッドを呼び出 toJSON
します)。元の PowerPoint.Shape オブジェクトは API オブジェクトですが、メソッドは、元の toJSON
オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として PowerPoint.Interfaces.ShapeData
型指定) を返します。
toJSON(): PowerPoint.Interfaces.ShapeData;
戻り値
Office Add-ins
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示