Jacob Adams
Jacob Adams

Reputation: 3994

Handle File->New in Word 2007

I am writing a VSTO addin for Word 2007. When the user selects File->New, (or selects it from the quick access toolbar) I need to display a custom form instead of the standard new document dialog. How do I do this? I don't see an application event I can handle and I can't seem to find the buttont to add an event handler too.

Upvotes: 2

Views: 2570

Answers (1)

Jacob Adams
Jacob Adams

Reputation: 3994

Ok, just found it. You need to create a Ribbon xml and then add commands for those buttons. In this case the ribbon xml is

<commands>
    <command idMso="FileNew" onAction="FileNewOverride"/>
    <command idMso="FileNewDefault" onAction="FileNewOverride"/>
</commands>

and the code behind is

public void FileNewOverride(Office.IRibbonControl control, ref bool cancelDefault)
    {
        //do something
    }

This how-to on MSDN shows you how to do it http://msdn.microsoft.com/en-us/office/dd361753.aspx

Upvotes: 2

Related Questions