Workbooks.Open not working from a service on Vista

M

Mark B

Bit of an odd one, but I cannot figure out why the Workbooks.Open command
produces an exception (see below) only when the command is run from a windows
service running on Vista.

So far I have discovered the following:
1. Its not version specific to Exel, I get the same result on version 2003
and 2007.

2. I can "see" and fully access the workbook from the service. I've done a
few tests involving using Shell to launch Excel with the workbook as well as
creating new files from the service, which both worked ok.

3. Ive tried late binding to the Excel application and invoking the Open
method, same exception.

4. I've verified that my code is working ok in a console app.

From looking up on the internet the exception is quite a generic one, as in
"something hasn't worked, i'm failing now", but heres the exception:

System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office
Excel cannot access the file 'C:\TestExcelService\Test_Excel.xlsx'. 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. at
Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object
UpdateLinks, Object ReadOnly, Object Format, Object Password, Object
WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object
Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru,
Object Local, Object CorruptLoad)

If anybody has any ideas on how to fix this I'd really appreciate it.
Thanks
Mark
 
J

Joel

I'm taking some guesses. With Excel 2003 try verifying the Default
directory. You may not have permissions for this directory.

from worksheet menu
tool - Option - General

Also see if the problem occurs on more than one PC. I would also check if
the Excel file is corrupted by going to Recover Application tool

Start - Microsoft Office - Tools - Recover Application.
 
Joined
May 15, 2009
Messages
1
Reaction score
0
I'm having the exact same problem. Workbooks.Open failing on service running on Vista. It is working through a console application, and the funny thing is that that console application is actually used by the service. So if I start the console app manually, the Excel call works, but if I start it from the Windows service, it fails. I'm running the Windows service in my own user account, so it shouldn't be a user/permission issue.

I'm still working on it. If I find a solution I'll post it here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top