主题
演示组件页码操作相关 API
当前页码
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
获取当前页码
语法
表达式.ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
表达式:文档类型应用对象
返回值
返回 Number 表示对应的当前页码
示例
//@file=base.pptx
async function example() {
  await instance.ready();
  const app = instance.Application;
  
  // 获取当前页码
  const curryPage = await app.ActivePresentation.SlideShowWindow.View.Slide.SlideIndex;
  console.log(curryPage);
}
跳转到指定页
ActivePresentation.SlideShowWindow.View.GotoSlide()
跳转到指定页
语法
表达式.ActivePresentation.SlideShowWindow.View.GotoSlide({ Index })
表达式:文档类型应用对象
参数
| 属性 | 数据类型 | 默认值 | 必填 | 说明 | 
|---|---|---|---|---|
| Index | Number | 是 | 跳转第 Index 个页面 | 
示例
//@file=base.pptx
async function example() {
  await instance.ready();
  const app = instance.Application;
  
  // 跳转到指定页
  await app.ActivePresentation.SlideShowWindow.View.GotoSlide(3);
}
监听页码改变
Sub.SlideSelectionChanged
监听当前页改变事件
语法
表达式.Sub.SlideSelectionChanged = eventHandle
表达式:文档类型应用对象
示例
//@file=base.pptx
async function example() {
  await instance.ready();
  const app = instance.Application;
  
  // 监听当前页改变事件
  app.Sub.SlideSelectionChanged = async (curryPage) => {
    console.log('切换到:', curryPage);
  };
}
总页码
ActivePresentation.Slides.Count
获取总页数
语法
表达式.ActivePresentation.Slides.Count
表达式:文档类型应用对象
返回值
返回 Number 表示对应的总页数
示例
//@file=base.pptx
async function example() {
  await instance.ready();
  const app = instance.Application;
  // 演示文稿对象
  const presentation = await app.ActivePresentation;
  // 幻灯片对象
  const slides = await presentation.Slides;
  
  // 获取总页数
  const count = await slides.Count;
  console.log(count);
}
 金山文档开放平台
金山文档开放平台