views:

209

answers:

2

I'm writing a Word COM Add-in that replaces the Open & Save dialogs with my own.

For the save dialog, I'm handling the documentBeforeSave event from the application events. This works fine.

For the open dialog, there is no such event, so I'm currently handling the onClick of the Open... menu item, canceling the default handling. This works ok if the user indeed uses this menu item, but if the user presses CTRL-O in stead they still get the original dialog.

Is there a better way to hook into this dialog? And if there isn't, is there a way to elegantly handle this keypress, or should I resolve to keyboard hooks?

Note: The add-in should eventually work on Office 2003, 2007 and 2010, but using different code-paths on different targets is of course perfectly fine. I am interested in any solutions on any version.

A: 

Hi , did you find solution. thanks Jan

jan
I did for Office 2007+ . See my own response I've had to mark as "answer".
Paul-Jan
A: 

In Word 2007+, this turns out to be incredibly simple to implement. Simply repurpose the FileOpen command through the ribbon XML

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"&gt;
  <commands>
    <command idMso="FileOpen" onAction="doOpen" />
  </commands>
  ...

The doOpen method then has two parameters, the second being an in/out parameter allowing you to cancel the event.

For previous version of Office, I've never implemented a fully bulletproof solution.

Paul-Jan