private void ExportToMSProjectButtonClick(object sender, RoutedEventArgs e) { Microsoft.Office.Interop.MSProject.Application msApplication = null; try { msApplication = new Microsoft.Office.Interop.MSProject.Application(); } catch (COMException) { MessageBox.Show("You need to have MSProject installed on your computer in order to use the export functionality of the example.", "No Installation"); return; } try { msApplication.AppMaximize(); msApplication.FileNew(Missing.Value, Missing.Value, Missing.Value, Missing.Value); var msProject = msApplication.ActiveProject; msProject.ManuallyScheduledTasksAutoRespectLinks = false; FillProjectWithTasks(msProject, this.radGanttView1.TasksSource.OfType<IGanttTask>(), null, false); FillTasksWithDependencies(msProject.Tasks.OfType<Task>(), this.radGanttView1.TasksSource.OfType<IGanttTask>()); msApplication.Visible = true; } catch (COMException) { try { msApplication.Quit(PjSaveType.pjDoNotSave); } catch (COMException) { return; } MessageBox.Show("You should not interact with MSProject while Exporting is performed! Please, export again.", "Interaction exception"); } }
private void ExportToMSProjectButtonClick(object sender, RoutedEventArgs e) { var msApplication = new Microsoft.Office.Interop.MSProject.Application(); msApplication.AppMaximize(); msApplication.FileNew(Missing.Value, Missing.Value, Missing.Value, Missing.Value); var msProject = msApplication.ActiveProject; msProject.ManuallyScheduledTasksAutoRespectLinks = false; FillProjectWithTasks(msProject, this.radGanttView1.TasksSource.OfType<IGanttTask>(), null, false); FillTasksWithDependencies(msProject.Tasks.OfType<Task>(), this.radGanttView1.TasksSource.OfType<IGanttTask>()); msApplication.Visible = true; }
private void ExportToMSProjectButtonClick(object sender, RoutedEventArgs e) { MessageBox.Show("MSProject will start exporting RadGanttView soon. While the process in running we do not recommend interacting with MS Project because the export might break.", "Start Exporting", MessageBoxButton.OK, MessageBoxImage.Information); try { msApplication = new Microsoft.Office.Interop.MSProject.Application(); } catch (COMException) { MessageBox.Show("You need to have MSProject installed on your computer in order to use the export functionality of the example.", "No Installation"); return; } System.Windows.Application.Current.MainWindow.WindowState = WindowState.Minimized; try { msApplication.AppMaximize(); msApplication.FileNew(Missing.Value, Missing.Value, Missing.Value, Missing.Value); var msProject = msApplication.ActiveProject; msProject.ManuallyScheduledTasksAutoRespectLinks = false; FillProjectWithTasks(msProject, this.radGanttView1.TasksSource.OfType <IGanttTask>(), null, false); FillTasksWithDependencies(msProject.Tasks.OfType <Task>(), this.radGanttView1.TasksSource.OfType <IGanttTask>()); msApplication.Visible = true; } catch (COMException) { try { msApplication.Quit(PjSaveType.pjDoNotSave); } catch (COMException) { return; } System.Windows.Application.Current.MainWindow.WindowState = WindowState.Normal; MessageBox.Show("Export has failed. Please, do not interact with MSProject while Exporting is performed.", "Interaction exception"); } }
// Constructor public CProject(ref MSProject.Application Application) { // sGlobalTemplate is our global MS Project objects string sGlobalTemplate = Properties.Settings.Default.TestDir + "SAPProject.mpt"; rApplication = Application; try { //Load our GlobalTemplate //rApplication.FileNew(false, @sGlobalTemplate, false, false); rApplication.FileNew(false, @sGlobalTemplate, false, false); } catch (IOException e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //Assign reference from standard MSProject to our own rProject = rApplication.ActiveProject; rTasks = rProject.Tasks; }