0
votes

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

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? - kennyzx
Thank you for the feedback @kennyzx. John Fitzpatrick's Answer on that post is helpful. - Shiasu-sama
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: social.msdn.microsoft.com/Forums/en-US/… - Shiasu-sama
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
@kennyzx Thank you. I'll focus on the HRESULT: 0x800A03EC error - Shiasu-sama

1 Answers

0
votes

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"