id: powerpoint-create-presentation name: Create presentation description: Creates a new, empty presentation and creates a new presentation by copying an existing one. author: OfficeDev host: POWERPOINT api_set: PowerPointApi: '1.1' script: content: |- document.getElementById("create-new-blank-presentation").addEventListener("click", () => tryCatch(createBlankPresentation)); document.getElementById("file").addEventListener("change", () => tryCatch(createPresentationFromExisting)); function createBlankPresentation() { PowerPoint.createPresentation(); } function createPresentationFromExisting() { const myFile = document.getElementById("file") as HTMLInputElement; const reader = new FileReader(); reader.onload = (event) => { // Remove the metadata before the Base64-encoded string. const startIndex = reader.result.toString().indexOf("base64,"); const copyBase64 = reader.result.toString().substr(startIndex + 7); PowerPoint.createPresentation(copyBase64); }; // Read in the file as a data URL so we can parse the Base64-encoded string. reader.readAsDataURL(myFile.files[0]); } /** Default helper for invoking an action and handling errors. */ async function tryCatch(callback) { try { await callback(); } catch (error) { // Note: In a production add-in, you'd want to notify the user through your add-in's UI. console.error(error); } } language: typescript template: content: |-

This sample shows how to create a new, empty presentation and how to create a new presentation by copying an existing one.

Try it out

Create empty presentation

Copy existing presentation

Select a PowerPoint presentation to copy and open in a new instance of PowerPoint.

language: html style: content: |- body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 14px; line-height: 1.5; padding: 10px; } section { margin-bottom: 20px; } h3 { margin-top: 0; margin-bottom: 10px; font-size: 16px; } p { margin: 0 0 10px 0; } button { background-color: #f0f0f0; color: #333333; border: 1px solid #8a8a8a; padding: 8px 16px; font-size: 14px; cursor: pointer; border-radius: 2px; margin-left: 20px; margin-bottom: 5px; min-width: 80px; display: block; } button:hover { background-color: #e0e0e0; } button:active { background-color: #d0d0d0; } input { padding: 8px; margin: 5px 0; border: 1px solid #ccc; border-radius: 2px; font-size: 14px; } .header { text-align: center; background-color: #f3f2f1; padding: 10px; } language: css libraries: |- https://appsforoffice.microsoft.com/lib/1/hosted/office.js https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/office-js/index.d.ts