0
votes

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:

  1. Open word
  2. Go to File -> Account -> Office updates. Disable updates
  3. 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

  4. Once done, confirm that the office version is updated to 16.0.9029.2253.

1
2 questions for you: a) did you tried the production CDN? we already shipped the API to production. b) can you provide a brief code snippet that reproduce your issue? that way we can better help you. thanks!Juan Balmori
Thanks @JuanBalmori . See above answers for more information.jsu

1 Answers

0
votes

ok, the problem with this snippet is that in the beta we used to allow the manipulation of the newly created document, we scoped that capability due to lack of multiplatform compatibility. so your create and open need to be on the same batch. We have a bug to fix to enable this in certain platforms, but certainly its not ready for prime time today.