Unanswered Office Project 2007 and C#

  • Tuesday, July 17, 2012 8:42 PM
     
      Has Code

    Hi all,

    My problem is this, I use an example I found on the web to create an Office Project file from c #, I want to take this example to an intranet, which I'm developing with c # and using DotNetNuke.

    On the server is installed project 2007, and the problem that I get every time I send my function call to create the file is as follows:

    Retrieving the COM class factory for component with CLSID {1019A320-508A-11CF-A49D-00AA00574C74} failed due to the Following Error: 80040154.

    The code I use is:

     public void export()
            {
    
                Project Proyecto = pj;
    
                Task subTarea = Proyecto.Tasks.Add("NameSubTask", subLine);
                subTarea.Start = "10/07/2012";
                subTarea.Finish = "12/07/2012";
                subTarea.AppendNotes("note");
               
                Resource user= Proyecto.Resources.Add("user", subLine);
                subTarea.Assignments.Add(subTask.ID, recurso.ID, Type.Missing);
    
    
                Task subTarea2 = Proyecto.Tasks.Add("NombreSubTarea2", subLine + 1);
                subTarea2.Start = "12/10/2009";
                subTarea2.Finish = "14/10/2009";
                subTarea2.AppendNotes("Nota adjunta a la subTarea2");
                subTarea2.Assignments.Add(subTarea2.ID, recurso.ID, Type.Missing);
               
                Task tareaPadre = Proyecto.Tasks.Add("NombreTareaPadre", 1);
                tareaPadre.Start = "10/10/2009";
                tareaPadre.Finish = "14/10/2009";
                tareaPadre.AppendNotes("Nota adjunta a la Tarea");
               tareaPadre;
                subTarea.OutlineIndent();
                subTarea2.OutlineIndent();
               
                pj.Application.GanttBarFormat(tareaPadre.ID, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.MSProject.PjColor.pjGreen, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
               
                pj.SaveAs(@"C:\", Microsoft.Office.Interop.MSProject.PjFileFormat.pjMPP, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, "MSProject.mpp.9", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
               
                //Aplicacion.FileClose(Microsoft.Office.Interop.MSProject.PjSaveType.pjDoNotSave, true); 
                //Cerrar la aplicación.
                pj.Application.Quit(Microsoft.Office.Interop.MSProject.PjSaveType.pjDoNotSave);
            }
            int subLine = 2;
    
              Microsoft.Office.Interop.MSProject.Project pj = new Project();
    
    I Use the COM libraries Office.Interop.MSProject and  the Office 12.0 Object Library

    I thank you in advance for your help and I am waiting for news.

    thanks!


    Victor Hugo Velázquez Chávez

All Replies

  • Wednesday, July 18, 2012 9:27 AM
     
     

    Do you have the relevant PIA installed on the server? You need the PIA as well as Project to be installed.

    You can get it here.

  • Wednesday, July 18, 2012 2:26 PM
     
     

    Are you using Project Server 2007 or Project 2007 Client COM API?

  • Thursday, July 19, 2012 2:05 PM
     
     
    Project 2007 Client

    Victor Hugo Velázquez Chávez

  • Thursday, July 19, 2012 2:22 PM
     
     

    Already downloaded and installed, but the error persists, if I make a windows application works fine but if I call the method from a Web control error appears

    thanks!


    Victor Hugo Velázquez Chávez

  • Friday, July 20, 2012 5:30 AM
     
     

    Hmm... in that case, it looks like one of those issues related to server side automation of Office applications, as described here...

    Considerations for server-side Automation of Office
    http://support.microsoft.com/kb/257757

  • Monday, July 23, 2012 3:28 AM
     
     
    Hi, you may see this C# word post on codeproject, using COM (Interop.Word).