navferty / NavfertyExcelAddIn

Common tools for MS Excel
MIT License
47 stars 6 forks source link

Undo action #34

Closed navferty closed 4 years ago

navferty commented 4 years ago

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.

navferty commented 4 years ago

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