navferty / NavfertyExcelAddIn

Common tools for MS Excel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undo action

navferty opened this issue · comments

Problem: Excel clears the undo stack with history of user actions after VBA macro or VSTO callback is executed.

Though we cannot restore all history of user actions, we can dump the state of book before any change takes place OR log each action that modifies workbook data. After all actions, , so that user can undo the last action - Add-In invocation.

It seems that we have to inject VBA command

Application.OnUndo "Primary Macro", "UndoPrimary"

to access to the undo action.

как вариант, обернуть все возможные для отмены вызовы интерцептором, который будет записывать адрес(а) ячейки/ячеек, и их старые значения. В конце метода, если этот метод допускает отмену, заинжектить VBA с пунктом отмены, по которому восстанавливать значения по списку