2016-02-18 34 views
1

我想在Word Online中使用以下代码打开base64编码文件。无法在Word Online中打开远程文件

function displayContents(myBase64) { 
    Word.run(function (context) { 
     console.log(Office.context.requirements.isSetSupported("WordApi", "1.1")); 

     // Create a proxy object for the document. 
     var thisDocument = context.document; 

     // Queue a command to clear the body contents. 
     thisDocument.body.clear(); 
     thisDocument.body.insertFileFromBase64(myBase64, "replace"); 

     // Create a proxy object for the default selection. 
     //var mySelection = thisDocument.getSelection(); 

     // Queue a command to insert the file into the current document. 
     //mySelection.insertFileFromBase64(myBase64, "replace"); 

     // Synchronize the document state by executing the queued commands, 
     // and return a promise to indicate task completion. 
     return context.sync(); 
    }) 
    .catch(function (error) { 
     console.log('Error: ' + JSON.stringify(error)); 
     if (error instanceof OfficeExtension.Error) { 
      console.log('Debug info: ' + JSON.stringify(error.debugInfo)); 
     } 
    }); 
} 

这不起作用(使用body.insertFileFromBase64或myselection.insertFileFromBase64)。该代码在Word的常规版本中起作用。我收到以下错误:

错误: “名”: “OfficeExtension.Error”, “代码”: “GeneralException”, “消息”: “此浏览器不支持请求的API。” “traceMessages”:[], “debuginfo软”:{}} LoadOfficeDoc.js:51调试信息:{}

Office.context.requirements.isSetSupported( “WordApi”, “1.1”)返回true。

我做错了什么或者这个功能在线不可用?

回答

3

新词API(使用Word.run例如有的话)目前仅支持在Word 2016在Windows(和iPad?)

虽然根据文档isSetSupported应返回false。

0

这是正确的,这实际上是一个我们正在处理的错误。 该要求集在WAC上不完全支持,因此该方法必须返回false。

+0

感谢您澄清胡安,这个功能是否会在网络版本中成为可能? –

+1

绝对!它很快就要来了! –

+0

此修复程序现在正在运行! Office.context.requirements.isSetSupported('WordApi',1.1)和Office.context.requirements.isSetSupported('WordApi',1.2)现在都返回false。 –