/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { string strAppName = (string)application.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, application, null); if (strAppName == "Microsoft Word") { appThis = new WordApp(application); } else if (strAppName == "Microsoft Excel") { appThis = new ExcelApp(application); } else if (strAppName == "Microsoft Publisher") { appThis = new PubApp(application); } else if (strAppName == "Microsoft Access") { appThis = new AccessApp(application); } else { string strError = String.Format("The '{0}' application is not supported!", strAppName); System.Windows.Forms.MessageBox.Show(strError, OfficeApp.cstrCaption); throw new Exception(strError); } if (connectMode != ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); } }
/// <summary> /// Implements the OnStartupComplete method of the IDTExtensibility2 interface. /// Receives notification that the host application has completed loading. /// </summary> /// <param term='custom'> /// Array of parameters that are host application specific. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnStartupComplete(ref System.Array custom) { // publisher in 2007 is still using the old style menus, but 2010 uses ribbons if (Application is PubApp) { // so if 2007, then get the old style menu loaded PubApp theApp = Application as PubApp; if (theApp.IsPublisher2007) { Application.LoadMenu(); } // the else case is that we use IRibbon... for the menu (which should be anything newer than 2007) // that is, this DLL isn't used for anything less than 2007 } }