Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows Application
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;
 
try
{
wb = Workbooks.Add(xlsFile.FullName);
template = xlsFile;
 
if (wb != null)
 
{
if (!DebugOut.IsDebug & wb.Worksheets.Count > 0)
((_Worksheet)wb.Worksheets[1]).Activate();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
throw new Exception("Error in OpenTemplate",ex);
}
return wb;
}
 
Any help and solution would be much appreaciated.
Posted 9-Apr-13 0:28am
rajaron370

1 solution

Rate this: bad
good
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
  Permalink  
Comments
rajaron at 9-Apr-13 5:57am
   
This is Windows Vista 32 bit OS
rajaron at 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 at 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.

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



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2014
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