Override built-in Office-functionality

O

Olaf Didszun

Using the modification options with the ribbon in Office 2007 it is possible
to add own code in the standard functionality of an Office component. As an
example we can add our own method to the FileSave-command. Whenever the user
uses the user interface, our code is accessed.

But, what, when the saving of the file is triggered via a macro? How can I
override these functions?

Thanks,

Olaf
 
K

Ken Slovak - [MVP - Outlook]

What Office application are you talking about? Each would have a different
event you'd have to handle depending on the application, if an event like
that is available.
 
O

Olaf Didszun

Hi Ken,

I have to handle the following events in Word, Excel, PowerPoint, Project
and Visio (all Office 2007)

- Save
- SaveAs
- Print
- Send as attachment

All could be handled (in Word, Excel and PowerPoint) with an onAction in the
ribbon, but when the user uses a makro, that for example saves the file, our
function is not called. I actually didn't have a look how Visio and Project
behave on this.

Thanks for you help!

Olaf
 
K

Ken Slovak - [MVP - Outlook]

Well, as an Outlook guy mostly I don't have all those events in memory for
all those applications :)

But a quick look at the object browser for Word gives me an
Application.BeforeDocument.Save() event. You'd need to subscribe to that
event for any open document or switch handlers when the ActiveWindow or
ActiveDocument changed. There's also an Application.DocumentBeforePrint()
event.

I'd just do the same for each object model you have to work with.

The Send To one could be a problem. That's going to hand off to the Simple
MAPI handler and I see no events for that, at least in Word.

Some things just might not be able to be trapped if there are no appropriate
object model events. That would depend on how the macro is written. If it
executes a button or ribbon control you'd trap it in on Action. Otherwise
you're at the mercy of the object model.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top