Share via

Insert widget/text at current cursor position

Anonymous
2020-01-27T09:03:16+00:00

How can we insert text or any other widget at current cursor position in ms-word from my ms-word plugin??

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2020-01-27T23:04:39+00:00

    Sorry, I cannot help with JS.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2020-01-27T11:13:18+00:00

    I am trying to implement this feature through JS. I tried using it but each time it prints the word on the default cursor position i.e left, right or center and moves to new line. If i have to do something like below:

    Hello {{insert text at this position}} 

    It doesnot happen. Text is inserted in new line on the left.What could be the issue.. Am I doing it wrong?

    This is the code i am using

    context.document

    .getSelection()

    .insertParagraph("{{"

    • this.state.value
    • "}}", Word.InsertLocation.before);

    Was this answer helpful?

    0 comments No comments
  3. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2020-01-27T10:49:36+00:00

    Use the command 

    Selection.InsertBefore

    Was this answer helpful?

    0 comments No comments