The office.js beta version not working with office 365 desktop version Microsoft Word 2016 MSO (16.0.9126.2152) 32-bit. The document.open() throws an error:
Document.open, OfficeExtension.Error
GeneralException: GeneralException
at Anonymous function (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:222335) at ai (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:267964) at ft (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:268051) at d (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:267871) at c (https://appsforoffice.microsoft.com/lib/beta/hosted/word-win32-16.01.js:21:266567) The beta version was working fine in an old office 365 version Microsoft Word 2016 MSO (16.0.9029.2253) 32-bit.
Edit
a) I'm using beta CDN version https://appsforoffice.microsoft.com/lib/beta/hosted/office.js with latest office 365 desktop version Microsoft Word 2016 MSO (16.0.9126.2152) because .open() method is still not available in production CDN. But it is available in beta see: https://github.com/OfficeDev/office-js-docs/tree/WordJs_OpenSpec
b) Basically I want to create and open the document. For that using createdocument method and passing base64encode file. There after some find and replace operations(e.g. finding 'Test' and replacing with 'Hello World') and opening it using .open(). It was working till old office 365 version Microsoft Word 2016 MSO (16.0.9029.2253).
Word.run(function (context) {
var myNewDoc = context.application.createDocument(base64File);
var searchResults = '';
return context.sync()
.then(function () {
searchResults = myNewDoc.body.search('{{Test}}', { matchCase: true });
context.load(searchResults);
})
.then(context.sync)
.then(function () {
for (var i = 0; i < searchResults.items.length; i++) {
searchResults.items[i].insertText('Hello World', Word.InsertLocation.replace);
}
})
.then(context.sync)
.then(function () {
myNewDoc.open();
});
})
.catch(errorHandler);
Same code I have double checked by restoring old version and worked fine. To restore old version follow the steps:
- Open word
- Go to File -> Account -> Office updates. Disable updates
Right-click cmd.exe, and then click Run as administrator. At command prompt run following commands:
a. cd %programfiles%\Common Files\Microsoft Shared\ClickToRun
b. officec2rclient.exe /update user updatetoversion=16.0.9029.2253
Once done, confirm that the office version is updated to 16.0.9029.2253.