none
Inserting/typing text in JavaScript RRS feed

  • Question

  • Hi,

    I am trying to insert a text from a web add-in as if the user typed it. For VSTO, Selection.TypeText seems to be what I am looking for, but I cannot find the equivalent in JavaScript.

    If there is none, how can I insert text so that the caret moves after the inserted text?

    I tried using Office.context.document.setSelectedDataAsync but that not only keeps the text selected, worse, it does not return focus to the document, so the user cannot continue typing or navigating the document with keyboard.

    I also tried using context.document.getSelection().insertText with every Word.InsertLocation possible, but none moves the cursor after the inserted text, so subsequent typing or insertText calls inserts the text before the previously inserted text, in addition to loosing the focus.

    Anything I missed? typeText equivalent? Collapsing the selection equivalent? Moving the caret? Focusing the document?

    Thanks,
    Jan




    • Edited by Jan Kučera Wednesday, August 14, 2019 3:55 PM
    Wednesday, August 14, 2019 3:54 PM