Repurpose builtin Word commands - access original command within repurposed function

Posted by Aurril on Stack Overflow See other posts from Stack Overflow or by Aurril
Published on 2010-04-21T12:18:09Z Indexed on 2010/04/21 12:23 UTC
Read the original article Hit count: 195

It is possible to repurpose a Word builtin command in Word 2007 using the customUI.xml file.

Example:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <commands>
     <command idMso="Save" onAction="MySave"/>
    </commands>
</customUI>

I then have to define a callback function in VBA which is used instead of the builtin function:

'Callback for Save onAction
Sub MySave(control As IRibbonControl, ByRef cancelDefault)
     someFancyPreparationFunction
     oldSaveFunction ' Where, how?
     someOtherFancyAfterWorkFunction
End Sub

And here is my problem, if I want to reuse internal functionality in my repurposed Function, I don't know how to access it. My example is trivial and the save could be easily rebuilt by a call to ThisDocument.save but as I said, it is just an example to show the problem. A call to CommandBars.ExecuteMso('Save') would call my repurposed function and not the original one. Any ideas on how to access the internal functionality after repurposing would be very appreciated!

© Stack Overflow or respective owner

Related posts about word2007

Related posts about customui