Pages
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 |
|
|
Get current slide index |
|
|
Listen for slide changes |
|
|
Jump to a slide |
|
Get the total number of slides
Returns the total number of slides in the presentation.
-
Syntax
Expression.ActivePresentation.Slides.CountExpression: the document type application object.
-
Return value
Returns a
numberrepresenting 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.SlideIndexExpression: the document type application object.
-
Return value
Returns a
numberrepresenting 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 = eventHandleExpression: 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); }