public Boolean OpenMSPProject(String sProjectID) { // Open an MS Project .mpp file for merging with SAP Data, // If the file open fails then SAP data is loaded signifying // a new project. // TestDir stores the merger working .mpp file String sTemp = Properties.Settings.Default.TestDir + sProjectID; try { //Load the existing .mpp file rApplication.FileOpen(sTemp, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.MSProject.PjPoolOpen.pjDoNotOpenPool, Missing.Value, Missing.Value, Missing.Value, Missing.Value); //Assign reference from opened MSProject to our own rProject = rApplication.ActiveProject; rTasks = rProject.Tasks; } catch (COMException ex) { //FileOpen failed return(false); } return(true); }
// 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; }