2017-01-19 16 views
0

我正在開發一個插件使用office.js ms字,但我得到錯誤時,試圖打電話range.insertContentConrol()像這樣link在範圍witch是word文檔選擇range.This是我的代碼:Office.js拋出GeneralException異常,當試圖insertContentControl在選擇

function insertContentControl(outPutText) { // Run a batch operation against the Word object model. Word.run(function (context) { //context.document.body.insertText("test", ""); // Create a proxy range object for the current selection. var range = context.document.getSelection(); // Queue a commmand to create the content control. var myContentControl = range.insertContentControl(); myContentControl.tag = outPutText; myContentControl.title = 'test'; //myContentControl.style = 'Heading 2'; myContentControl.insertText(outPutText, 'replace'); myContentControl.cannotEdit = true; 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)); } }); }

和值的outputText可能是「[1]」女巫是讓其他函數返回。

+0

您能分享您的內部版本號和平臺嗎?謝謝 –

+0

好吧,office-js build版本是16.0.6207.1000,ms word 2016版本是1611(內部版本7571.2109),用於windows – asa9891

+0

這是一個相當老的版本,如果你可以更新到最新並在那裏嘗試,那將是非常好的。 –

回答