7

We were unable to open an Excel Workbook with ASP.net before creating a folder named "Desktop" in the systemprofile Folder.

The solution was to create a folder named "Desktop" in C:\Windows\SysWOW64\config\systemprofile\

Error Message:

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file 'c:\temp\test.xls'.

There are several possible reasons:

  • The file name or path does not exist.
  • The file is being used by another program.
  • The workbook you are trying to save has the same name as a currently open workbook.

Does any one know an explanation for this?

If found a tip here: Excel 2007 automation on top of a Windows Server 2008 x64

But I do not understand how this Desktop folder is related to Excel or InteropServices in general.

Version Information:

OS: Windows Server 2012

IIS: Internet Information Services (Version 8.0.9200.16384)

Excel: Excel 2013

Rizwan
  • 103
  • 4
  • 24
Matthias
  • 1,386
  • 3
  • 24
  • 59
  • Do you simple need to read data from an Excel file? If so - use ADO.NET and OLEDB provider instead of messing with COM – Yuriy Galanter Mar 17 '14 at 15:59
  • My colleague wrote an vb.net web application importing Excel data to read but also to write Excel data (creates xlsx files). – Matthias Mar 17 '14 at 16:03
  • is this a general problem that COM interop calls can cause such creepy effects? – Matthias Mar 17 '14 at 16:09
  • Is the ASP.NET application on a server, and these folders are all setup on that server? – Brian Mains Mar 17 '14 at 16:14
  • Yes. This Folder has been created on the Server to solve this. I have full Access to the Server. We were not facing this issue when we were Debugging on our local machines. – Matthias Mar 17 '14 at 16:23
  • 1
    You're going down an unsupported path. The office applications were built on the expectation that they're working with an interactive user and microsoft have *never* supported automating them from windows or web services. – Damien_The_Unbeliever Mar 18 '14 at 08:13
  • You mean These Office.interops should not be done in ASP.net in General? So there must be better ways to work with Excel in ASP.net (both reading and writing in a similar way or we have to rewrite the application) – Matthias Mar 18 '14 at 08:18
  • The AppPool user must be localsystem too... It's an unsupported path but it's a need, so I see why M$ doesn't care but the work must be done. – SparK Oct 13 '15 at 14:26
  • Just a guess from my side: Excel creates some temporary files in the folder. When the folder does not exist, then this error occurs. – knut Aug 19 '16 at 10:30
  • It might be enough to run the Excel COM component as interactive user as suggested [here](https://forums.asp.net/t/1740537.aspx?Microsoft+Excel+cannot+access+the+file+is+solved+by+creating+a+folder+). – Turbo Feb 05 '18 at 12:20
  • It’s not supported but it’s working. You just have to know how to setup all this. I’m using word/excel automation on windows server 2012 and 2014, IIS and web forms. About 300 user every day using excel and word to generate reports, like you can do with crystal reports etc. the fun begins when you have to work with access as dB with classic asp and office automation on a new 64 bit windows server. But everything is possible if you want – BR75 Jun 19 '19 at 19:53

0 Answers0