Pages

更新时间:
复制 MD 格式

This topic describes how to obtain the total number of slides, listen to the page change events, and jump to a specified slide when you use a presentation document.

Obtain the total number of slides

Obtain the total number of slides in a presentation document.

  • Syntax

    Expression.ActivePresentation.Slides.Count

    Expression: the document type application object.

  • Return value

    Returns a number that represents the total number of slides.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain the presentation document object.
      const presentation = await app.ActivePresentation;
    
      // Obtain the slide objects.
      const slides = await presentation.Slides;
      
      // Obtain the total number of slides.
      const count = await slides.Count;
      console.log(count);
    }

Obtain the page number of the current slide

Obtain the page number of the current slide.

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.Slide.SlideIndex

    Expression: the document type application object.

  • Return value

    Returns a number that represents the page number of the current slide.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the page number of the current slide.
      const curryPage = await app.ActivePresentation.SlideShowWindow.View.Slide.SlideIndex;
      console.log(curryPage);
    }

Listen to page change events

Listen to the page change events of the current slide.

  • Syntax

    Expression.Sub.SlideSelectionChanged = eventHandle

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Listen to the page change events of the current slide.
      app.Sub.SlideSelectionChanged = async (curryPage) => {
        console.log ('Change to:', curryPage);
      };
    }

Jump to a specified slide

Jump to a specified slide.

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.GotoSlide({ Index })

    Expression: the document type application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    Index

    Number

    Yes

    The index number of the slide that you want to jump to.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Jump to the specified page.
      await app.ActivePresentation.SlideShowWindow.View.GotoSlide(3);
    }