使用 Javascript 加载项操作 PowerPoint?

Manipulating PowerPoint with Javascript Add-in?

我正在尝试制作 PowerPoint Web 插件。我已经阅读了Office JavaScript API documentation,但不是很详细。

您知道允许以下功能的功能吗:

目前无法在 PowerPoint 演示文稿中插入新幻灯片。您只能使用 Document.goToByIdAsync().

在现有幻灯片之间导航

但是可以将文本块或图像插入现有幻灯片。这是使用 Document.setSelectedDataAsync() 方法完成的。

例如:

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 在加载项 API 功能方面一直落后于其他 Office 应用程序。我强烈建议访问 UserVoice 并添加您的建议(并为其他人投票)。这对于为未来投资 PPT API 功能提供理由非常有帮助。