0
votes

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.

3
Did you check all possible reasons? What was the result of that check?Dirk Vollmar
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

3 Answers

2
votes

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.

0
votes

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

0
votes

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.