4

I'm looking for a way to override Undo (CtrlZ) / Redo (CtrlZ) commands in Word 2010 (C# + VSTO). Is it possible ?

I managed to catch Copy / Paste commands, but it seems that Undo / Redo are not commands in RibbonUI like Copy / Paste.

udondan
  • 52,841
  • 19
  • 186
  • 168
Geotinc
  • 289
  • 1
  • 4
  • 20

1 Answers1

6

If you want some control over what happens with Undo/Redo, check out Microsoft.Office.Interop.Word.UndoRecord. Here's the thread where I learnt to use it properly!

If you want to catch the actual keystrokes, then you're in Windows API land. So generally, Google terms related to that. But message-hooks-in-add-ins may be useful to you.

JasonPlutext
  • 14,984
  • 3
  • 43
  • 83
  • Hi, thanks for your answer but I don't see how this link can help me. This link just show how to add a custom record into undo / redo drop down list. What I want is to catch Ctrl+Y / CTRL+Z. There are no events in UndoRecord class. – Geotinc Aug 02 '12 at 06:13
  • 1
    I'm surprised that there are no other way to do this. I think using global hook means using heavy artillery. – Geotinc Aug 02 '12 at 14:19
  • Here is the VSTO Keyboard Hooking I use: http://stackoverflow.com/a/10257266/495455 – Jeremy Thompson Dec 05 '16 at 01:14