Reputation: 16845
I'm developing an Office Add-In for Power Point. An example from the documentation about how to change slide is:
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");
}
});
}
However, with this API I want to get the current slide id. Seems like there is no such a function in the Office-JS API.
How do I get this information?
Upvotes: 1
Views: 1624
Reputation: 14649
We can get the current index of active slide via using the document.getSelectedDataAsync method. Here is an example for your reference:
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);
}
});
Note, the function is an asynchronous method. The result maybe not expected when you change the slide quickly after you call this method
Upvotes: 2