Can I programmatically detect when Word is undoing an action?
-
Monday, April 09, 2012 7:50 PM
In my project, I had to use WindowSelectionChange to update the ribbon according the selection in the document.
But when the user click the “undo” button and the program goes through my WindowSelectionChange routine, all the reference to the model commands (which were working perfectly well in the normal “positive” moment) are lost and arise a run time error 6197 ( which description in a loosely translation is "Model's objects command not available in the present event").
If I could programmatically know when word is performing an undoing action I could force the program to exit my WindowSelectionChange before the error arise.
Sorry, because I already formulated this problem in a slightly different way in this post.
Thanks, Lauro
All Replies
-
Monday, April 09, 2012 8:14 PM
I think what you'll want to do is Temporarily Repurpose the Undo Command. The link provides a "how to" article for you to follow.
When you trap the Undo you'll set a boolean value and then let the Undo continue. In your WindowSelectionChange you'll check the boolean switch, reset it and then perform or not what ever needs to be done or undone.
Hope this helps
Kind Regards, Rich ... http://greatcirclelearning.com
- Edited by Rich Michaels Monday, April 09, 2012 8:15 PM
-
Monday, April 09, 2012 8:45 PM
-
Tuesday, April 10, 2012 12:33 AM
Oh Well ... another day of learning for me.
I see that the Undo is a gallery control type and in Word 2010 I don't get an error for trying to repurpose it, but it also doesn't work. <sigh>
Kind Regards, Rich ... http://greatcirclelearning.com
-
Thursday, April 12, 2012 3:33 PMModerator
Hi,
Your question falls into the paid support category which requires a more in-depth level of support. Please visit the below link to see the various paid support options that are available to better meet your needs.
http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone
best regards,
Forrest Guo | MSDN Community Support | Feedback to manager

