编程语言
首页 > 编程语言> > javascript – Office.context.document.getFileAsync抛出错误

javascript – Office.context.document.getFileAsync抛出错误

作者:互联网

我得到一个非常奇怪的问题,当我尝试将word文档提取为压缩文件以便在我的MS Word任务窗格MVC应用程序中进行第三次处理时,它会爆炸.

这是代码:

Office.context.document.getFileAsync(Office.FileType.Compressed, function (result) {
if (result.status == "succeeded") {
    var file = result.value;

    file.getSliceAsync(0, function (resultSlice) {
        //DO SOMETHING
    });
} else {
    //TODO: Service fault handling?
}
});

出现的错误代码是5001.我不知道如何解决这个问题.

如果您对此有任何想法,请告诉我.

额外细节:

解决方法:

来自MSDN:

No more than two documents are allowed to be in memory; otherwise the
getFileAsync operation will fail. Use the File.closeAsync method to
close the file when you are finished working with it.

确保在再次读取文件之前调用File.closeAsync – 这可以解释您所看到的问题.

更多:https://msdn.microsoft.com/en-us/library/office/jj715284.aspx

标签:javascript,ms-office,apps-for-office
来源: https://codeday.me/bug/20190830/1768418.html