Esempio n. 1
0
 private void Application_WorkbookBeforeClose(Excel.Workbook wb, ref bool cancel)
 {
     if (!cancel)
     {
         this.PendingRequest = new CloseRequestInfo(
             wb.Name,
             this.Application.Workbooks.Count);
     }
 }
Esempio n. 2
0
 private void Application_WorkbookDeactivate(Excel.Workbook wb)
 {
     if (this.Application.Workbooks.Count == 1)
     {
         // With only one workbook available deactivating means it will be closed
         this.PendingRequest = null;
         this.OnWorkbookClosed(new WorkbookClosedEventArgs(wb.Name));
     }
 }
Esempio n. 3
0
        private void Application_WorkbookActivate(Excel.Workbook wb)
        {
            // A workbook was closed if a request is pending and the workbook count decreased
            bool wasWorkbookClosed = true &&
                                     this.PendingRequest != null &&
                                     this.Application.Workbooks.Count < this.PendingRequest.WorkbookCount;

            if (wasWorkbookClosed)
            {
                var args = new WorkbookClosedEventArgs(this.PendingRequest.WorkbookName);
                this.PendingRequest = null;
                this.OnWorkbookClosed(args);
            }
            else
            {
                this.PendingRequest = null;
            }
        }