2016-11-17 42 views
2

使用WordApi 1.3時,應該可以使用新的createDocument method從web addIns中創建新文檔。使用WordApi時context.application未定義1.3

但是,使用文檔中找到的以下示例代碼段時,context.applicationundefined

Word.run(function (context) {  // lets hold a valid base64 docx on this variable...   
    var myStartingDocAsBase64 = "some valid base64 encoded docx"; 
    var myNewDoc = context.application.createDocument(myStartingDocAsBase64); // note that the parameter is optional, a blank doc will be created otherwise    // at this point you can use the entire API on the myNewDoc document.. you can do things like   
    myNewDoc.body.insertParagraph("This is a new paragraph added via API", "end");  //now lets open the document, after this method is called, you will no longer be able to modify the doc.....   
    myNewDoc.open(); 
    return context.sync();  
}) 
.catch(function (e) { 
    console.log(e.message); 
}) 

即使Office.context.requirements.isSetSupported("WordApiDesktop", "1.3")返回true。

這是在Windows 10上的Office 1611中測試的(如下圖所示)。 Office version

1.3中的功能尚未完全實現嗎,還是我們應該採取其他措施以使createDocument正常工作?

+0

剛剛發現了描述相同問題的這個github問題(https://github.com/OfficeDev/office -js-DOCS /問題/ 385) –

回答

1

你好,謝謝你的問題。所有這些仍然在預覽中,因此可能會發生變化。這裏有一些指導給你。

  1. 1.WordApiDesktop需求設置沒有這樣的事情,它很快就會被刪除並且不再存在於Office.js中。 的事實是有一個錯誤,所以謝謝你報告這個。
  2. 如果您看到您共享的文檔頁面,則當前處於預覽狀態的1.3需求中的應用程序對象及其createDocument方法當前(且可能會更改)。 (使用office.js https://appsforoffice.microsoft.com/lib/beta/hosted/office.js的預覽CDN)

所以請不要使用WordApiDesktop要求,也是確保您使用的是BETA CDN的Office.js

其良好的百達要有最新的Office來測試預覽,請查看此頁面,以便在您不在最新的情況下尋求幫助:https://github.com/OfficeDev/office-js-docs/blob/215f5d35490c943cc06c29b98357ba8cb034ec81/docs/develop/install-latest-office-version.md