Reputation: 213
I've build an app relying on the user to make certain selections and the app then react accordingly.
However i want to deselect the selected text after the app has done the work.
I can not see anywhere in the API an option to allow me to deselect the current selection.
Is this not possible?
Upvotes: 3
Views: 1392
Reputation: 33124
You can use the select() method and pass in either 'start'
or 'end'
as the parameter. This will result in deselecting the text and placing the cursor at either the start or end of the object.
Do deselect the current selection you can use the following:
Word.run(function (context) {
var range = context.document.getSelection();
range.select('start');
return context.sync();
})
Note that you can execute this against a range, paragraph or entire body so body.select('start')
will place the cursor at the beginning of the document while paragraph.select('start')
will place it at the beginning of the current paragraph.
Upvotes: 6