1

Im builing an office app that will run inside Microsoft Word. I'm using office.js create it.

So far I have been able to insert text into the document using the API, but the text it inserts, appears selected, making the app UX suffer since the user has to make one extra click to lose focus to insert another text without replacing the inserted one.

Here is how the code looks like:

function insertEquation()
{
    Office.context.document.setSelectedDataAsync("`x = (-b +-sqrt(b^2-4ac))/(2a)`", { coercionType: 'text' });
}

I just want the text not to appear selected.

Thanks in advance.

Nicolas Saul
  • 143
  • 1
  • 11

1 Answers1

0

To insert some text in the document I would insert a Paragraph like so:

function insertText(text) {
        Word.run(function (context) {
            context.document.body.insertParagraph(text, Word.InsertLocation.start);
        });
    }
C1rdec
  • 1,647
  • 1
  • 21
  • 46