我正在尝试使用新的Powerpoint的Office.js应用程序接口,它目前还处于预览阶段。我无法使用PowerPoint.run()方法调用任何东西,因为它的行为似乎与Excel和Word中的不同。有人能帮我找到一种可行的方法来调用这里引用的SlideCollection.getCount()方法吗?
示例代码(假设我需要在尝试获取计数之前先加载项):
PowerPoint.run(function (context) {
var properties = context.presentation.slides.items;
context.load(properties);
return context.sync()
.then(function() {
console.log(properties);
})
.catch((error) => console.log(error));
})发布于 2020-11-21 07:01:40
下面是对slides.getCount()的调用,它应该可以工作
PowerPoint.run(async (context) => {
context.presentation.load("slides");
await context.sync();
var slides = context.presentation.slides;
var slideCount = slides.getCount();
await context.sync();
console.log("There are ", slideCount.value, " slides in this presentation");
}发布于 2021-09-08 08:50:47
PowerPoint.run(async function (context) {
context.presentation.load("slides");
await context.sync();
const slide = context.presentation.slides.getItemAt(0);
slide.load("id");//you just load any property from PPT object model and then sync
await context.sync();
console.log(slide.id);
});https://stackoverflow.com/questions/64896713
复制相似问题