The solution I was really working on was the following:
- Save a copy of the clipboard state
- Clear clipboard
- Create the data I want in tab / newline delimited format, push it to clipboard
- Simulate Ctrl + V operation in Excel
- Clear clipboard
- Restore clipboard to its original state
Obviously, this is localized for cell manipulation, so you cannot push arbitrary operations / callbacks onto the undo stack. In addition, I clearly violate the principles of using the clipboard in Windows, but if Microsoft provides the best API for such things (a hint), I would not have to.
Also, I did not go with the solution that I described in the first comment on David Zemens's answer, because I hit some security breaches in our environment (i.e. injecting VBA code into the book does not matter).
Anyway, thanks to everyone!
Richard Pianka
source share