如何在 Office 加载项 API 中获取 PowerPoint 当前幻灯片索引?
How to get PowerPoint current slide index in Office Add-In API?
我正在开发 Office Add-In for Power Point. An example from the documentation about how to change slide 是:
function goToSlideByIndex() {
var goToNext = Office.Index.Next;
Office.context.document.goToByIdAsync(goToNext, Office.GoToType.Index, function (asyncResult) {
if (asyncResult.status == "failed") {
showMessage("Action failed with error: " + asyncResult.error.message);
}
else {
showMessage("Navigation successful");
}
});
}
但是,通过这个 API 我想获取当前的幻灯片 ID。 Office-JS API.
好像没有这个功能
我如何获得这些信息?
我们可以通过document.getSelectedDataAsync方法获取当前活动幻灯片的索引。这里有一个例子供您参考:
Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, function (asyncResult) {
if (asyncResult.status == "failed") {
app.showNotification("Action failed with error: " + asyncResult.error.message);
}
else {
app.showNotification(asyncResult.value.slides[0].index);
}
});
注意,该函数是一个异步方法。调用此方法后快速更换幻灯片可能会出乎意料
我正在开发 Office Add-In for Power Point. An example from the documentation about how to change slide 是:
function goToSlideByIndex() {
var goToNext = Office.Index.Next;
Office.context.document.goToByIdAsync(goToNext, Office.GoToType.Index, function (asyncResult) {
if (asyncResult.status == "failed") {
showMessage("Action failed with error: " + asyncResult.error.message);
}
else {
showMessage("Navigation successful");
}
});
}
但是,通过这个 API 我想获取当前的幻灯片 ID。 Office-JS API.
好像没有这个功能我如何获得这些信息?
我们可以通过document.getSelectedDataAsync方法获取当前活动幻灯片的索引。这里有一个例子供您参考:
Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, function (asyncResult) {
if (asyncResult.status == "failed") {
app.showNotification("Action failed with error: " + asyncResult.error.message);
}
else {
app.showNotification(asyncResult.value.slides[0].index);
}
});
注意,该函数是一个异步方法。调用此方法后快速更换幻灯片可能会出乎意料