System.Runtime.InteropServices.COMException (0x800A03EC)

131,937

Solution 1

Found Answer.......!!!!!!!

Officially Microsoft Office 2003 Interop is not supported on Windows server 2008 by Microsoft.

But after a lot of permutations & combinations with the code and search, we came across one solution which works for our scenario.

The solution is to plug the difference between the way Windows 2003 and 2008 maintains its folder structure, because Office Interop depends on the desktop folder for file open/save intermediately. The 2003 system houses the desktop folder under systemprofile which is absent in 2008.

So when we create this folder on 2008 under the respective hierarchy as indicated below; the office Interop is able to save the file as required. This Desktop folder is required to be created under

C:\Windows\System32\config\systemprofile

AND

C:\Windows\SysWOW64\config\systemprofile

This worked for me...

Also do check if .NET 1.1 is installed because its needed by Interop and ot preinstalled by Windows Server 2008

Or you can also Use SaveCopyas() method ist just take onargument as filename string)

Thanks Guys..!

Solution 2

Try this as it worked for me...

  1. Go to "Start" -> "Run" and enter "dcomcnfg"
  2. This will bring up the component services window, expand out "Console Root" -> "Computers" -> "DCOM Config"
  3. Find "Microsoft Excel Application" in the list of components.
  4. Right click on the entry and select "Properties"
  5. Go to the "Identity" tab on the properties dialog.
  6. Select "The interactive user."

courtesy of Last paragraph mentioned in here

Solution 3

Some googling reveals that potentially you've got a corrupt file:

http://bitterolives.blogspot.com/2009/03/excel-interop-comexception-hresult.html

and that you can tell excel to open it anyway with the CorruptLoad parameter, with something like...

Workbook workbook = excelApplicationObject.Workbooks.Open(path, CorruptLoad: true);

Solution 4

I was seeing this same error when trying to save an excel file. The code worked fine when I was using MS Office 2003, but after upgrading to MS Office 2007 I started seeing this. It would happen anytime I tried to save an Excel file to a server or remote fie share.

My solution, though rudimentary, worked well. I just had the program save the file locally, like to the user's C:\ drive. Then use the "System.IO.File.Copy(File, Destination, Overwrite)" method to move the file to the server. Then you can delete the file on the C:\ drive.

Works great, and simple. But admittedly not the most elegant approach.

Hope this helps! I was having a ton of trouble finding any solutions on the web till this idea popped into my head.

Solution 5

It 'a permission problem when IIS is running I had this problem and I solved it in this way

I went on folders

C:\Windows\ System32\config\SystemProfile

and

C:\Windows\SysWOW64\config\SystemProfile

are protected system folders, they usually have the lock.

Right-click-> Card security-> Click on Edit-> Add untente "Autenticadet User" and assign permissions.

At this point everything is solved, if you still have problems try to give all permissions to "Everyone"

Share:
131,937
Sameer S
Author by

Sameer S

Updated on January 11, 2022

Comments

  • Sameer S
    Sameer S over 2 years

    Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs() method is working fine on Windows server 2003 and also on XP but not on Windows server 2008. I copied it as it is gave all Dll's and permissions

    I have also tried all the solutions given on the net, such as Culture settings and DCOM permission.

    Getting following error:

    System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC

    at

    Microsoft.Office.Interop.Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local)

    Please help ..!

  • Kapil Kshirsagar
    Kapil Kshirsagar about 10 years
    I have just used SaveCopyas() instead of SaveAs() and added impersonate in web.config and its working!
  • Muflix
    Muflix over 9 years
    How do you used SaveCopyAs() instead of SaveAs() when the methods have differents parameters for example save format ?
  • trailmax
    trailmax over 9 years
    @daniele3004 If I remember correctly, the problem was that I was getting zero number of rows. So I added check for numberOfRows > 0 and the problem got fixed.
  • benshabatnoam
    benshabatnoam almost 8 years
    I've created the desktop folders and it is working perfectly again. Thanks so match, I whould have never found the issue myself
  • Nickolas Hook
    Nickolas Hook over 7 years
    Also be sure to set appropriate Write/Create Permissions on the created Desktop folders.
  • xverges
    xverges over 7 years
    Worked (almost) like a charm: images in my Excel file were missing. Solved it by dealing with the existence/persmission of INetCache in the same folder stackoverflow.com/a/41161719/239408
  • sofsntp
    sofsntp almost 7 years
    please add desktop in the path to make it more explicit at first glance
  • nate_weldon
    nate_weldon over 6 years
    I had this same issue. The was garbage data in the excel file. Opening it up manual in excel and removed the bad data any everything worked. I also tried with the CorruptLoad as well. This worked
  • benshabatnoam
    benshabatnoam about 6 years
    10q my friend, I've tried everything and nothing worked in my case except your answer.