Skip to content

Instantly share code, notes, and snippets.

@scips
Created October 6, 2022 10:36
Show Gist options
  • Save scips/547b1f3e032a56c147c3c138d09ddde4 to your computer and use it in GitHub Desktop.
Save scips/547b1f3e032a56c147c3c138d09ddde4 to your computer and use it in GitHub Desktop.
Gets the title, index, and ID of the selected slide(s).
name: Get slide metadata
description: 'Gets the title, index, and ID of the selected slide(s).'
host: POWERPOINT
api_set: {}
script:
content: |
$("#get-slide-metadata").click(getSlideMetadata);
function getSlideMetadata() {
Office.context.document.getSelectedDataAsync(Office.CoercionType.SlideRange, function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
console.error(asyncResult.error.message);
} else {
let slide_titles=[];
if (asyncResult.value['slides'] !== null) {
for (let slide of asyncResult.value['slides']) {
slide_titles.push(slide['title']);
}
$("#slide-titles").text(slide_titles.join("\n"));
console.log(slide_titles);
}
//console.log(JSON.stringify(asyncResult.value, null, 4));
}
});
}
language: typescript
template:
content: "<section class=\"ms-font-m\">\n\t<p class=\"ms-font-m\">Get slide Titles.</p>\n\t<p class=\"ms-font-m\">Select one or more slides and click <b>Get slide Titles</b></p>\n</section>\n\n<button id=\"get-slide-metadata\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Get slide Titles</span>\n</button>\n\n<textarea id=\"slide-titles\">\n\n</textarea>"
language: html
style:
content: |-
section.samples {
margin-top: 20px;
}
section.samples .ms-Button, section.setup .ms-Button {
display: block;
margin-bottom: 5px;
margin-left: 20px;
min-width: 80px;
}
language: css
libraries: |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css
core-js@2.4.1/client/core.min.js
@types/core-js
jquery@3.1.1
@types/jquery@3.3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment