I have an application in Asp .Net Mvc3, i am using the mpxj library for to generate a project file (with extension mpx). But this file not contain dates for Tasks, then i want to open the file with Ms Project and then save with the new format (Ms project create Dates for tasks). Detail is that i want to do it automatically. Is it possible? What is the best way?
I know that interop
MsOffice
in Asp.NET not is recommended http://support.microsoft.com/kb/257757.
But the need to automatically calculate dates, I am handling errors, and I am using MsProject Interop
. This is my code:
Microsoft.Office.Interop.MSProject.Application app = new Microsoft.Office.Interop.MSProject.Application();
app.DisplayAlerts = false;
app.AskToUpdateLinks = false;
app.FileOpenEx(
Server.MapPath("") + "\\sample.mpx",
false,
Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,
PjPoolOpen.pjPoolReadWrite, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Microsoft.Office.Interop.MSProject.Project pj=app.ActiveProject;
app.CalculateAll(); //Para calcular las fechas
app.FileSaveAs(Server.MapPath("") + "\\sample.mpp",PjFileFormat.pjMPP, Type.Missing, Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);