0

I'm trying to use: Microsoft.Office.Interop.MSProject Document Export to export my excel file to PDF as an alternative to Worksheet.ExportAsFixedFormat which causes some HRESULT problems like:

Exception from HRESULT: 0x800A03EC

I have no idea how to use MSProject, but here's what I've tried:

  1. Added the MSProject Reference to my WPF Project: Microsoft.Office.Interop.MSProject (Version 15.0.0.0)
  2. Replaced my Worksheet.ExportAsFixedFormat code with:

    Microsoft.Office.Interop.MSProject.Application mainMSProjectApplication = new Microsoft.Office.Interop.MSProject.Application();
    mainMSProjectApplication.DocumentExport(path, Microsoft.Office.Interop.MSProject.PjDocExportType.pjPDF, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    

I get an exception on the first line:

Retrieving the COM class factory for component with CLSID {36D27C48-A1E8-11D3-BA55-00C04F72F325} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

  1. Then I tried: Windows Key > "Run": regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.MSProject.dll"

I then get this Error:

The module "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.MSProject.dll" was loaded but the entry-point DllRegisterServer was not found.

Any help would be appreciated

Shiasu-sama
  • 1,179
  • 2
  • 12
  • 39
  • 1
    This is not the right path to go. MSProject is the library for another Office file type and you cannot use it to automate `Excel` files. Fix the `Exception from HRESULT: 0x800A03EC`: can it be caused by using backward compatible file (.xls not .xlsx) or something else like the ones in [this post](https://stackoverflow.com/questions/7099770/hresult-0x800a03ec-on-worksheet-range)? – kennyzx Jan 14 '19 at 10:45
  • Thank you for the feedback @kennyzx. John Fitzpatrick's Answer on that post is helpful. – Shiasu-sama Jan 14 '19 at 11:19
  • I was led to MSProject by this comment: "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." by Bill.B_ on this link: https://social.msdn.microsoft.com/Forums/en-US/bb52147f-1195-41e9-b61f-07f9c8177928/exportasfixedformat-method-of-msproject-is-not-working-in-vsto-2013?forum=project2010custprog – Shiasu-sama Jan 14 '19 at 11:40
  • 1
    the key is, project and excel are two different file types! the thread you found is about Project, and has nothing to with Excel. DocumentExport seems to be unique to the Project file type, you just can’t use it. – kennyzx Jan 14 '19 at 13:17
  • @kennyzx Thank you. I'll focus on the HRESULT: 0x800A03EC error – Shiasu-sama Jan 15 '19 at 07:17

1 Answers1

0

It seems my:

Exception from HRESULT: 0x800A03EC

Was caused by me specifying a path that some Users didn't have permissions to write to.

Changing the path in ExportAsFixedFormat to the "My Documents" directory fixed the problem.

As kennyzx commented:

"This is not the right path to go. MSProject is the library for another Office file type and you cannot use it to automate Excel files"

Shiasu-sama
  • 1,179
  • 2
  • 12
  • 39