1

I have create Office Excel application in my machine(XP). and i have placed the application in windows server 2008 giving the following error.

Microsoft Office Excel cannot access the file '\server\Input.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.

both client and server systems installed office 2007 and added reference microsoftexcellibrary 12.0

created assembly for the application and calling the code from the form.

Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
Nag
  • 19
  • 1
  • 3
  • Did you check all possible reasons? What was the result of that check? – Dirk Vollmar Oct 29 '10 at 09:09
  • You will have to be more specific than "windows server". And, an Excel spreadsheet is not a standalone application. "created assembly for the application and calling the code from the form": how is this form and VB.Net exe intended to interact with the file? Office VBA is not VB.Net. VB.Net is not Excel. Though it would be nice if it was. As a workaround, VBA always has access to the "Scripting.FileSystemObject" COM class. – bob-the-destroyer Oct 29 '10 at 09:29

3 Answers3

3

I was getting the exact same error, although in my case I was trying to run (from Tidal Enterprise Scheduler) a .NET app that used microsoft.interop.excel.

The answer is already in stackoverflow: [Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'.

I'll re-list the steps from that link:

  1. Create directory “C:\Windows\SysWOW64\config\systemprofile\Desktop” (for 64 bit Windows) or “C:\Windows\System32\config\systemprofile\Desktop” (for 32 bit Windows)

  2. Set full control permissions on Desktop directory above (for example in Win7 & IIS 7 & DefaultAppPool set permissions for user “IIS AppPool\DefaultAppPool”)

Of course, if you're running a scheduled task rather than WebApp, you'll need to make sure the service account you're using has permissions on that folder.

Community
  • 1
  • 1
Farskeptic
  • 2,910
  • 2
  • 19
  • 15
0

I would make sure no Excel processes are running on the machine before you run this application, that should cover the last point.

The first point looks the most likely issue, the path looks like a partial path or an incorrect UNC path. Try putting the full path to the spreadsheet 'C:\server\input.xls' and see if that works.

To stop the middle point, in the workbook.open command you can specify to open as read-only, this will make sure the application can red the file even if it is locked open by another user.

halfer
  • 19,824
  • 17
  • 99
  • 186
DJIDave
  • 735
  • 5
  • 19
  • I have tested the same app in local machine it is working. when i placed the same logic in the server it is giving error. – Nag Oct 29 '10 at 09:59
  • It could be that the spreadsheet on the server is open by someone else (as I don't know the layout of your systems), so it would work happly with your local version but fail on the server. It is also possible for you to have another version of the spreadsheet on your local system that in relation to the exe is discoverable, but there is no spreadsheet in the relative path on the server. – DJIDave Oct 29 '10 at 10:09
  • I am using shared path from the other server. – Nag Oct 29 '10 at 10:16
  • the path is \\\Input.xls same when i executed on machine and server. but it is failing in server only. excel = New Excel.Application wBook = excel.Workbooks.Add("\\\Input.xls") even wBook.SaveAs("\\\TestJobCompare.xlsm", 52) is failing if i remove code of copying the Input.xls. Exception from HRESULT: 0x800A03EC i suspect this is relating to permissions or windowsserver 2008. – Nag Oct 29 '10 at 10:20
0

I had the same error when trying to save to:

C:\test.xlsx

When attempting to save to the root directory, it seemed to cause problems. Changing my path to:

C:\MyExcelTests\test.xlsx

Worked fine

Alex
  • 4,821
  • 16
  • 65
  • 106