Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Runtime.InteropServices.COMException (0x800A03EC)

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 ..!

like image 902
Sameer S Avatar asked Dec 10 '10 11:12

Sameer S


People also ask

How do I fix Hresult 0X800A03Ec?

Typically, Excel Error Hresult 0X800A03Ec errors are caused by a corrupt or missing Microsoft Excel-associated file, sometimes due to malware infection. File replacement is typically the best and easiest way to resolve errors related to Microsoft Corporation files.

What is a COMException?

COMException(String, Exception) Initializes a new instance of the COMException class with a specified error message and a reference to the inner exception that is the cause of this exception. COMException(String, Int32) Initializes a new instance of the COMException class with a specified message and error code.


2 Answers

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..!

like image 82
Sameer S Avatar answered Sep 19 '22 20:09

Sameer S


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

like image 21
Pratik Gaikwad Avatar answered Sep 17 '22 20:09

Pratik Gaikwad