2
votes

I am trying to make a PowerPoint Web Add-in. I have read the Office JavaScript API documentation but it wasn't very detailed.

Do you know functions that permit to:

  • Create a new slide programmatically by an Office Add-in

  • Add text areas inside a slide programmatically by an Office Add-in.

1

1 Answers

2
votes

It isn't possible to insert a new slide into a PowerPoint presentation at the moment. You can only navigate between existing slides using Document.goToByIdAsync().

It is possible to insert a text block or image into an existing slide however. This is done using the Document.setSelectedDataAsync() method.

For example:

function writeText() {
    Office.context.document.setSelectedDataAsync("Hello World!",
        function (asyncResult) {
            var error = asyncResult.error;
            if (asyncResult.status === Office.AsyncResultStatus.Failed) {
                console.log(error.name + ": " + error.message);
            }
        });
}

PowerPoint has been notoriously behind the other Office applications in terms of Add-in API functionality. I would highly recommending visiting the UserVoice and adding your suggestions (and voting up others). This will be super helpful when it comes to making a case for future investment into PPT API functionality.