none
Can I programmatically detect when Word is undoing an action? RRS feed

  • Question

  • 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
    Monday, April 9, 2012 7:50 PM

All replies

  • 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


    Monday, April 9, 2012 8:14 PM
  • Thanks for your answer Rich, but Undo is not a repurposable command.

    See also this tread.

    Lauro

    Monday, April 9, 2012 8:45 PM
  • 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

    Tuesday, April 10, 2012 12:33 AM
  • 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

    Thursday, April 12, 2012 3:33 PM
    Moderator