anmolsarraf
anmolsarraf

Reputation: 157

How to clear Word undo stack using Javascript API for Word

I am creating a Word add-in using Javascript API for Word, wherein the user searches for a phrase and the phrase gets highlighted in the document. There is also a reset button, which restores the document to the pre-search state. Here, two events are getting added to the undo stack.

[some state A]
1. phrase highlighting
2. undo phrase highlighting
[same state A]

Is there a way I can achieve state A without adding two events in the undo stack? Like, if the user presses Ctrl+Z, they do not go through step 2 and step 1.

Upvotes: 2

Views: 363

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33114

I'm afraid not. You cannot manipulate the undo stack from an add-in today.

There is however a UserVoice request for this functionality that could use your votes: Remove Changes Made by the Javascript API for Office from the Undo Stack

Upvotes: 2

Related Questions