OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
687 stars 95 forks source link

RichAPI.Error: General Exception when reading content of footer on Word 64 Bit #4956

Closed MichaelL79 closed 4 weeks ago

MichaelL79 commented 1 month ago

In a Word Addin we are reading the contents of the primary footer. This works very well on most installations but when used with Word 64 Bit we always get an error "RichAPI.Error: General Exception"

Environment

Expected behavior

Should work as with Word 32 Bit

Current behavior

Always throws mentioned exception

Steps to reproduce

Exception happens at the second context.sync

 Word.run(function (context) {

     const sections = context.document.sections;
     context.load(sections, 'items/body/footers/primary');

     return context.sync().then(function () {

         var footer = sections.items[0].getFooter("primary");
         context.load(footer, 'body');

         footer.load('text');
         footer.load('fields');
         footer.paragraphs.load('items');

         const fields = footer.fields.load(["code", "result", "locked", "type", "data", "kind"]);

         context.sync().then(function () { //>>exception happens here

             fields.items.forEach(function (field) {
                 //reading fields
             });

         });
     });
 }).catch(function (error) {
     console.log("Error: " + error);
     if (error instanceof OfficeExtension.Error) {
         console.log("Debug info: " + JSON.stringify(error.debugInfo));
     }
 });
qinliuMSFT commented 1 month ago

Hi @MichaelL79 , thank you for reporting this issue.

The Word.FieldCollection included in API set: WordApi 1.4, is not available on volume-licensed perpetual Office versions. image

The Office version number: Word LTSC MSO (16.0.14332.20734) 64-Bit is volume-licensed perpetual Office versions, have you tried isSetSupported to check if the specified requirement set is supported by this Office application?

MichaelL79 commented 1 month ago

Hi @qinliuMSFT, thanks for the quick response and the clarification. Does this mean it is not possible to read fields with LTSC versions of Word? To me, this seams like a very basic task and it is a little strange this is not supported. Is there a different way to achive the same?

Best regards, Michael

qinliuMSFT commented 4 weeks ago

Hi @MichaelL79 , sorry, there is currently no such way.