Word Addin JS RichAPI /General exceptionerror when using getText() for fetching paragraphs

Rathan K 0 Reputation points
2025-02-12T04:45:53.65+00:00
await Word.run(async (context) => {
      const document = context.document;
      const body = document.body;
      const paragraphs = body.paragraphs;

      paragraphs.load({ $all: true });
      let listItems = [];
      let paragraphText = {};
      await context.sync();

      for (let i = 0; i < paragraphs.items.length; i++) {
        paragraphGUIDHash.set(paragraphs.items[i].uniqueLocalId, true);
        listItems.push(paragraphs.items[i].listItemOrNullObject);
        listItems[i].load("listString");
      }

      try {
        await context.sync();
      } catch (error) {
        console.log("Loading error for list paragraph api!!!");
      }

      for (let i = 0; i < paragraphs.items.length; i++) {
        paragraphText[i] = paragraphs.items[i].getText({ IncludeHiddenText: false, IncludeTextMarkedAsDeleted: false});
      }

      let sectionsJson = [];
      let currentSection = [];
      let sectionCount = 1;

      try {
        await context.sync();
      } catch (error) {
        console.log("Loading error for paragraph text!!!");
      }

})

The issue over here when i use getText() i run into Richapi error and i found it on word addin PC version of windows with Office 365 version 2308 (Build 16731.20948) on our client side. But the issue seems to be not there when we use getReviewedText().

Same issue we are not over observing on our side windows with Office 365 version 2501 (Build 18429.20132). Now Can any let me know what's the issue here because on last context.sync() getting RichApi.Error: GeneralException error.

Is there any way this can be fixed with latest version of Office JS or should have fall back mechanism everytime to switch between getText() and getReviewedText().

Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
955 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,043 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,262 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.