在 Office 365 中使用 Office javascript API 使用 Base64 创建新文档

问题描述 投票:0回答:1

使用此功能,我在 Word 中使用

base64String
创建新文档,这在 Word 桌面版本中有效,但在 Office 365 中不起作用。

async function CreateNewDoc(event) {
    try {
        await Word.run(async (context) => {
            // Use the Base64-encoded string representation of the selected .docx file.
            const externalDocument = base64;
            var externalDoc = context.application.createDocument(externalDocument);
            await context.sync();
            externalDoc.open();
            event.completed();
            await context.sync();
        });
    } 
    catch (error) {
        event.completed();
        console.error(error);
    }
}

Office 365 上出现错误消息

The action isn't supported by Word in a browser
这意味着 Office 365 尚不支持此功能?

javascript office-js add-in word-addins
1个回答
0
投票

Word Online 不支持 context.application.createDocument。您可以通过此链接获取相关信息[createDocument API定义][1]

[1]:https://learn.microsoft.com/en-us/javascript/api/word/word.documentcreated?view=word-js-preview。有很多属性具有 WordApiHiddenDocument 1.3 API 集,这是仅桌面集。

谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.