//************************************************************************* // Constructor: AutomateTasksDialog() // /// <summary> /// Initializes a new instance of the <see cref="AutomateTasksDialog" /> /// class. /// </summary> /// /// <param name="thisWorkbook"> /// Workbook containing the graph contents. /// </param> /// /// <param name="ribbon"> /// The application's Ribbon. /// </param> //************************************************************************* public AutomateTasksDialog ( ThisWorkbook thisWorkbook, Ribbon ribbon ) { Debug.Assert(thisWorkbook != null); Debug.Assert(ribbon != null); m_oAutomateTasksUserSettings = new AutomateTasksUserSettings(); m_oThisWorkbook = thisWorkbook; m_oRibbon = ribbon; InitializeComponent(); // Instantiate an object that saves and retrieves the user settings for // this dialog. Note that the object automatically saves the settings // when the form closes. m_oAutomateTasksDialogUserSettings = new AutomateTasksDialogUserSettings(this); DoDataExchange(false); AssertValid(); }
//************************************************************************* // Constructor: AutomateTasksDialog() // /// <summary> /// Initializes a new instance of the <see cref="AutomateTasksDialog" /> /// class. /// </summary> /// /// <param name="thisWorkbook"> /// Workbook containing the graph contents. /// </param> /// /// <param name="ribbon"> /// The application's Ribbon. /// </param> //************************************************************************* public AutomateTasksDialog( ThisWorkbook thisWorkbook, Ribbon ribbon ) { Debug.Assert(thisWorkbook != null); Debug.Assert(ribbon != null); m_oAutomateTasksUserSettings = new AutomateTasksUserSettings(); m_oThisWorkbook = thisWorkbook; m_oRibbon = ribbon; InitializeComponent(); // Instantiate an object that saves and retrieves the user settings for // this dialog. Note that the object automatically saves the settings // when the form closes. m_oAutomateTasksDialogUserSettings = new AutomateTasksDialogUserSettings(this); DoDataExchange(false); AssertValid(); }
//************************************************************************* // Method: AutomateTasksOnOpen() // /// <summary> /// Runs task automation on the workbook immediately after it is opened. /// </summary> //************************************************************************* public void AutomateTasksOnOpen() { AssertValid(); AutomateTasksUserSettings oAutomateTasksUserSettings = new AutomateTasksUserSettings(); try { TaskAutomator.AutomateThisWorkbook(this, oAutomateTasksUserSettings.TasksToRun, this.Ribbon); } catch (Exception oException) { ErrorUtil.OnException(oException); return; } if ( (oAutomateTasksUserSettings.TasksToRun & AutomationTasks.ReadWorkbook) != 0 ) { // The graph is being asynchronously laid out in the graph pane. // Wait for the layout to complete. GraphLaidOutEventHandler oGraphLaidOutEventHandler = null; oGraphLaidOutEventHandler = delegate(Object sender, GraphLaidOutEventArgs e) { // In case something went wrong while automating this workbook, // prevent this delegate from being called again. this.GraphLaidOut -= oGraphLaidOutEventHandler; OnTasksAutomatedOnOpen(); }; this.GraphLaidOut += oGraphLaidOutEventHandler; } else { OnTasksAutomatedOnOpen(); } }