Pages

Updated at:

Get the total number of slides, track the current slide, listen for slide changes, and navigate to any slide in a presentation.

Operation

API

Get total slide count

Expression.ActivePresentation.Slides.Count

Get current slide index

Expression.ActivePresentation.SlideShowWindow.View.Slide.SlideIndex

Listen for slide changes

Expression.Sub.SlideSelectionChanged = eventHandle

Jump to a slide

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

Get the total number of slides

Returns the total number of slides in the presentation.

  • Syntax

    Expression.ActivePresentation.Slides.Count

    Expression: the document type application object.

  • Return value

    Returns a number representing the total number of slides.

  • Example

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

Get the current slide index

Returns the index of the slide currently displayed in the presentation.

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.Slide.SlideIndex

    Expression: the document type application object.

  • Return value

    Returns a number representing the 1-based index of the current slide.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Get the index of the current slide (1-based).
      const currentPage = await app.ActivePresentation.SlideShowWindow.View.Slide.SlideIndex;
      console.log(currentPage);
    }

Listen for slide changes

Registers a callback that fires whenever the current slide changes.

  • Syntax

    Expression.Sub.SlideSelectionChanged = eventHandle

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Register a callback for slide changes.
      // The callback receives the index of the newly active slide.
      app.Sub.SlideSelectionChanged = async (currentPage) => {
        console.log('Changed to slide:', currentPage);
      };
    }

Jump to a slide

Navigates the presentation to a specific slide by its index.

  • Syntax

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

    Expression: the document type application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    Index

    Number

    Yes

    The 1-based index of the target slide.

  • Example

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