Click here to Skip to main content
13,087,566 members (93,360 online)
Rate this:
Please Sign up or sign in to vote.
I am using a Windows based application which uses COM Interop Excel in which the excel exports fails. This works in the development environment. But it fails when promoted to other environment.

Also the problem is it is not reproducible in local environment.

We are using Microsoft.Interop.Excel for opening the excel and updating the data.

While trying to add the workbook using Workbooks.Add method we are getting the following
error :

System.Runtime.InteropServices.COMException.Exception from HRESULT:0X800A03EC
at Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template)

Code :

thisWorkbook = OpenTemplate(new System.IO.FileInfo("XLSTemplate\\Test.xlsx"));

public Workbook OpenTemplate(FileInfo xlsFile)
Workbook wb = null;

wb = Workbooks.Add(xlsFile.FullName);
template = xlsFile;

if (wb != null)

if (!DebugOut.IsDebug & wb.Worksheets.Count > 0)
catch (Exception ex)
throw new Exception("Error in OpenTemplate",ex);
return wb;

Any help and solution would be much appreaciated.
Posted 8-Apr-13 23:28pm
Updated 23-Sep-16 8:48am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Are the OS different in both environment? Is it Window 2008 Server? If so try creating Desktop folder as below if not present already in the environment where this is failing.

Windows 2008 Server (64 Bit): C:\Windows\SysWOW64\config\systemprofile\Desktop
Windows 2008 Server (32 Bit): C:\Windows\System32\config\systemprofile\Desktop
rajaron 9-Apr-13 5:57am
This is Windows Vista 32 bit OS
rajaron 9-Apr-13 6:28am
Hi Prashanth,

The Operation System is Windows Vista - 32 Bit.

But can you say me as how the 32 bit/ 64 bit is associated with Interop excel
PrashantSonewane 9-Apr-13 6:35am
Its not related to Interop exel. I was check checking if your OS is server and 64 bit. If it is 64 bit, there is another folder for system files SysWOW64 unlike 32 bit. Hence you need to create Desktop folder both the places. Bit here is not related to Excel interop but with OS. Anyway yours is 32 bit. Will reply if find breakthrough or clue.
Manju0520 23-Sep-16 15:03pm
I faced Exact same issue on a Windows 2008 Server (64 Bit). Creating a Desktop folder as mentioned by Prashanth resolved my issue. Thanks for this Question and Answer :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 23 Sep 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100