ExportAsFixedFormat method of MSProject is not working in VSTO 2013. RRS feed

  • Question

  • Hi All,

    The method ExportAsFixedFormat() of Microsoft.Office.Interop.MSProject.Project is not working. I am getting exception like "An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code" and "Additional information: The argument value is not valid".

    I have code below:-

    Microsoft.Office.Interop.MSProject.Project thisDoc = Globals.ThisAddIn.Application.ActiveProject;
                string thisDocTempPath = Path.GetTempFileName();
                thisDoc.ExportAsFixedFormat(thisDocTempPath, PjDocExportType.pjPDF);

    Could you please let me know, what am I doing wrong?



    Tuesday, January 12, 2016 10:00 AM

All replies

  • Hi Lalit,

    Please ensure that you can export the project to PDF successfully when you operate the Project application manually.

    If not, you can try to repair the Project application to see whether the issue was fixed.

    And since this forum is for developers discussing developing issues about Office add-in, I would move this thread to the Project Customization and Programming forum to discussing Project developing issues.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thanks for your understanding.

    Regards & Fei

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 13, 2016 3:16 AM
  • Thanks Fei...

    Yes,we are able export the project to PDF successfully when we operate the Project application manually..



    Wednesday, January 13, 2016 5:47 AM
  • Have you checked to see what the value is in theDocTempPath? Maybe it doesn't like the .tmp extension? Have you tried to export to a hard-coded filename?
    Wednesday, January 13, 2016 3:34 PM
  • Yes. the DocTempPath is "\AppData\Local\Temp\tmp781B.tmp" and also tried with hard-coded path like "C:\Users\abc\Desktop\Project1.mpp". but getting same exception.
    Thursday, January 14, 2016 5:26 AM
  • Try hard-coding the DocTempPath with a .pdf extension like "C:\Users\abc\Desktop\Project1.pdf", since that's the format you're trying to export to.
    Thursday, January 14, 2016 3:09 PM
  • Thanks for the response.

    Tried with hard coded value(C:\Users\lalit\Desktop\Sample.pdf), still getting same exception.



    Friday, January 15, 2016 4:56 AM
  • Use the Application.DocumentExport method instead. It looks to do the same thing and it didn't give me an error when I tried it while the other method did.

    Friday, January 15, 2016 3:42 PM
  • Thanks Bill, It is working fine.

    I am curious, why ExportAsFixedFormat()  is not working?

    Thanks in advance.



    Monday, January 18, 2016 5:55 AM