private void ThisAddIn_Startup(object sender, System.EventArgs e) { try { InitializeLogger(); } catch { // we want to silently fail here. Logging won't work, but at least it won't bring down the app. } try { SupportEmailAddress = SitecoreClient.GetContactEmail(); } catch (Exception ex) { SupportEmailAddress = ""; this.LogException("Unable to retrieve email for support!", ex); } try { InitializePlugin(); _startup = new Word.ApplicationEvents4_DocumentChangeEventHandler(Application_DocumentChange); _beforeCloseHandler = new ApplicationEvents4_DocumentBeforeCloseEventHandler(Application_BeforeDocumentClose); Application.DocumentChange += _startup; Application.DocumentOpen += OpenArticleInformationWindowIfNeeded; Application.DocumentBeforeClose += _beforeCloseHandler; Application.DocumentChange += Application_DocumentChange_UpdateRibbon; } catch (Exception ex) { Log("Exception occurred during startup: " + ex.Message); Log("stack trace: " + ex.StackTrace); } }
protected override void OnAfterLoad() { closeDocumentEvent = DocumentClosed; }