2

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Jacob Adams
  • 3,944
  • 3
  • 26
  • 42

1 Answers1

2

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

Jacob Adams
  • 3,944
  • 3
  • 26
  • 42
  • Do you have a link to a current copy of the page? Your link is now dead, and the archive.org page will redirect as well - https://web.archive.org/web/20120212042034/http://msdn.microsoft.com/en-us/office/dd361753.aspx – Michael Paulukonis Jul 15 '14 at 15:29
  • also adding if you want to Override File -> Save change "FileNew" to "FileSave" – Selwyn Mar 27 '17 at 04:13