PowerPoint.SlideScopedCollection class

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

Extends

注釈

API セット: PowerPointApi 1.5

使用元

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

// Saves which shapes are selected so that they can be reselected later.
await PowerPoint.run(async (context) => {
  context.presentation.load("slides");
  await context.sync();
  const slides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides();
  const slideCount = slides.getCount();
  slides.load("items");
  await context.sync();
  savedSlideSelection = [];
  slides.items.map((slide) => {
    savedSlideSelection.push(slide.id);
  });
  const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
  const shapeCount = shapes.getCount();
  shapes.load("items");
  await context.sync();
  shapes.items.map((shape) => {
    savedShapeSelection.push(shape.id);
  });
});

プロパティ

context

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

items

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

メソッド

exportAsBase64Presentation()

このコレクション内のすべてのスライドを、Base64 エンコード データとして返される専用のプレゼンテーション ファイルにエクスポートします。

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.SlideScopedCollection オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、コレクションの項目から読み込まれたプロパティの浅いコピーを含む "items" 配列を含むプレーンな JavaScript オブジェクト ( PowerPoint.Interfaces.SlideScopedCollectionData として型指定された) を返します。

プロパティの詳細

context

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

context: RequestContext;

プロパティ値

items

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

readonly items: PowerPoint.Slide[];

プロパティ値

メソッドの詳細

exportAsBase64Presentation()

このコレクション内のすべてのスライドを、Base64 エンコード データとして返される専用のプレゼンテーション ファイルにエクスポートします。

exportAsBase64Presentation(): OfficeExtension.ClientResult<string>;

返品

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

注釈

API セット: PowerPointApi 1.10

getCount()

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

getCount(): OfficeExtension.ClientResult<number>;

返品

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

注釈

API セット: PowerPointApi 1.5

getItem(key)

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

getItem(key: string): PowerPoint.Slide;

パラメーター

key

string

スライドの ID。

返品

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

注釈

API セット: PowerPointApi 1.5

getItemAt(index)

コレクション内の 0 から始まるインデックスを使用してスライドを取得します。

getItemAt(index: number): PowerPoint.Slide;

パラメーター

index

number

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

返品

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

注釈

API セット: PowerPointApi 1.5

getItemOrNullObject(id)

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

getItemOrNullObject(id: string): PowerPoint.Slide;

パラメーター

id

string

スライドの ID。

返品

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

注釈

API セット: PowerPointApi 1.5

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

// Uses getItemOrNullObject to find a slide by ID within the selected slides.
// If the ID isn't found in the selected slides, the returned object's isNullObject property is true.
// If the ID is found in the selected slides, presentation displays that slide.
await PowerPoint.run(async (context) => {
  const slideId = (document.getElementById("slide-id-input") as HTMLInputElement).value.trim();
  if (!slideId) {
    console.log("Enter a slide ID in the text box first.");
    return;
  }

  const selectedSlides: PowerPoint.SlideScopedCollection = context.presentation.getSelectedSlides();

  // getItemOrNullObject returns a Slide object without throwing if the ID isn't found.
  const slide: PowerPoint.Slide = selectedSlides.getItemOrNullObject(slideId);
  slide.load("id");
  await context.sync();

  if (slide.isNullObject) {
    console.log(`Slide ID "${slideId}" was not found in the selected slides.`);
  } else {
    console.log(`Slide found in the selected slides.`);
    console.log(`  ID: ${slide.id}`);

    // Switch to the slide.
    context.presentation.setSelectedSlides([slide.id]);
    await context.sync();

    console.log(`Switched to the slide - ID: ${slide.id}`);
  }
});

load(options)

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

load(options?: PowerPoint.Interfaces.SlideScopedCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions): PowerPoint.SlideScopedCollection;

パラメーター

options

PowerPoint.Interfaces.SlideScopedCollectionLoadOptions & PowerPoint.Interfaces.CollectionLoadOptions

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

返品

load(propertyNames)

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

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

パラメーター

propertyNames

string | string[]

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

返品

load(propertyNamesAndPaths)

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

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

パラメーター

propertyNamesAndPaths
OfficeExtension.LoadOption

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

返品

toJSON()

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

toJSON(): PowerPoint.Interfaces.SlideScopedCollectionData;

返品