PowerPoint.SlideCollection class

プレゼンテーション内のスライドのコレクションを表します。

Extends

注釈

API セット: PowerPointApi 1.2

使用元

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml

const chosenMaster = (document.getElementById("master-id") as HTMLInputElement).value;
const chosenLayout = (document.getElementById("layout-id") as HTMLInputElement).value;

await PowerPoint.run(async function(context) {
  // Create a new slide using an existing master slide and layout.
  const newSlideOptions: PowerPoint.AddSlideOptions = {
    slideMasterId: chosenMaster, /* An ID from `Presentation.slideMasters`. */
    layoutId: chosenLayout /* An ID from `SlideMaster.layouts`. */
  };
  context.presentation.slides.add(newSlideOptions);
  await context.sync();
});

プロパティ

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

items

このコレクション内に読み込まれた子アイテムを取得します。

メソッド

add(options)

コレクションに新しいスライドを追加します。

exportAsBase64Presentation(values)

このコレクションに含まれている 1 つ以上のスライドを、Base64 でエンコードされたデータとして返される専用のプレゼンテーション ファイルにエクスポートします。 指定されたスライド ID または Slide オブジェクトがこのコレクションに見つからない場合は、InvalidArgument例外をスローします。

getCount()

コレクション内のスライドの数を取得します。

getItem(key)

一意の ID を使用してスライドを取得します。

getItemAt(index)

コレクション内の 0 から始まるインデックスを使用してスライドを取得します。 スライドは、プレゼンテーションと同じ順序で保存されます。

getItemOrNullObject(id)

一意の ID を使用してスライドを取得します。 そのようなスライドが存在しない場合は、 isNullObject プロパティが true に設定されたオブジェクトが返されます。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

toJSON()

API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.SlideCollection オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、コレクションの項目から読み込まれたプロパティの浅いコピーを含む "items" 配列を含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.SlideCollectionData として型指定された) を返します。

プロパティの詳細

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

items

このコレクション内に読み込まれた子アイテムを取得します。

readonly items: PowerPoint.Slide[];

プロパティ値

メソッドの詳細

add(options)

コレクションに新しいスライドを追加します。

add(options?: PowerPoint.AddSlideOptions): void;

パラメーター

options
PowerPoint.AddSlideOptions

省略可能。 新規スライドのプロパティを構成するためのオプション。

返品

void

注釈

API セット: PowerPointApi 1.3

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/add-slides.yaml

const chosenMaster = (document.getElementById("master-id") as HTMLInputElement).value;
const chosenLayout = (document.getElementById("layout-id") as HTMLInputElement).value;

await PowerPoint.run(async function(context) {
  // Create a new slide using an existing master slide and layout.
  const newSlideOptions: PowerPoint.AddSlideOptions = {
    slideMasterId: chosenMaster, /* An ID from `Presentation.slideMasters`. */
    layoutId: chosenLayout /* An ID from `SlideMaster.layouts`. */
  };
  context.presentation.slides.add(newSlideOptions);
  await context.sync();
});

exportAsBase64Presentation(values)

このコレクションに含まれている 1 つ以上のスライドを、Base64 でエンコードされたデータとして返される専用のプレゼンテーション ファイルにエクスポートします。 指定されたスライド ID または Slide オブジェクトがこのコレクションに見つからない場合は、InvalidArgument例外をスローします。

exportAsBase64Presentation(values: Array<string | Slide>): OfficeExtension.ClientResult<string>;

パラメーター

values

Array<string | PowerPoint.Slide>

スライド ID または Slide オブジェクトの配列。

返品

Base64 でエンコードされた文字列。

注釈

API セット: PowerPointApi 1.10

getCount()

コレクション内のスライドの数を取得します。

getCount(): OfficeExtension.ClientResult<number>;

返品

コレクション内のスライドの数。

注釈

API セット: PowerPointApi 1.2

getItem(key)

一意の ID を使用してスライドを取得します。

getItem(key: string): PowerPoint.Slide;

パラメーター

key

string

スライドの ID。

返品

一意の ID を持つスライド。 そのようなスライドが存在しない場合は、エラーがスローされます。

注釈

API セット: PowerPointApi 1.2

getItemAt(index)

コレクション内の 0 から始まるインデックスを使用してスライドを取得します。 スライドは、プレゼンテーションと同じ順序で保存されます。

getItemAt(index: number): PowerPoint.Slide;

パラメーター

index

number

コレクション内のスライドのインデックス。

返品

指定したインデックス位置のスライド。 index が範囲外の場合は、エラーがスローされます。

注釈

API セット: PowerPointApi 1.2

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/slide-management/get-set-slides.yaml

// Selects slides 2, 4, and 5.
await PowerPoint.run(async (context) => {
  context.presentation.load("slides");
  await context.sync();
  const slide2: PowerPoint.Slide = context.presentation.slides.getItemAt(1);
  const slide4: PowerPoint.Slide = context.presentation.slides.getItemAt(3);
  const slide5: PowerPoint.Slide = context.presentation.slides.getItemAt(4);
  slide2.load("id");
  slide4.load("id");
  slide5.load("id");
  try {
    await context.sync();
  } catch (error) {
    console.warn("This action requires at least 5 slides in the presentation.");
    return;
  }
  await context.sync();
  context.presentation.setSelectedSlides([slide2.id, slide4.id, slide5.id]);
  await context.sync();
});

getItemOrNullObject(id)

一意の ID を使用してスライドを取得します。 そのようなスライドが存在しない場合は、 isNullObject プロパティが true に設定されたオブジェクトが返されます。 詳細については、「 *OrNullObject のメソッドとプロパティ」を参照してください。

getItemOrNullObject(id: string): PowerPoint.Slide;

パラメーター

id

string

スライドの ID。

返品

一意の ID を持つスライド。

注釈

API セット: PowerPointApi 1.2

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(options?: PowerPoint.Interfaces.SlideCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions): PowerPoint.SlideCollection;

パラメーター

options

PowerPoint.Interfaces.SlideCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions

読み込むオブジェクトのプロパティのオプションを指定します。

返品

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames?: string | string[]): PowerPoint.SlideCollection;

パラメーター

propertyNames

string | string[]

読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。

返品

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths?: OfficeExtension.LoadOption): PowerPoint.SlideCollection;

パラメーター

propertyNamesAndPaths
OfficeExtension.LoadOption

propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。

返品

toJSON()

API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の PowerPoint.SlideCollection オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、コレクションの項目から読み込まれたプロパティの浅いコピーを含む "items" 配列を含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.SlideCollectionData として型指定された) を返します。

toJSON(): PowerPoint.Interfaces.SlideCollectionData;

返品