0
votes

I'm getting the error:

Microsoft Excel cannot access the file '..\services\Calculator.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.

Any ideas?

I tried this, but does not seem to work Microsoft Office Excel cannot access the file 'c:\inetpub\wwwroot\Timesheet\App_Data\Template.xlsx'

Dim xlApp As Application = New Application
Dim xlWB As Workbook
xlWB = xlApp.Workbooks.Open(Server.MapPath("~") + "\services\Calculator.xlsx", 2, True)

Dim xlSheet As Worksheet = xlWB.Sheets("input output")

xlSheet.Cells(7, 8).value = drpTrades.SelectedValue
xlSheet.Cells(12, 8).value = Convert.ToDecimal(txtIncome.Text)
xlSheet.Cells(9, 8).value = loan.Text

Dim xlRebate As Decimal = xlSheet.Cells(18, 8).value
If xlRebate < 0 Then lblRebate.ForeColor = System.Drawing.Color.Red
lblRebate.Text = "£" + Math.Round(xlRebate, 2).ToString

xlWB.Close(False)
xlApp.Quit()
ReleaseComObject(xlApp)
xlApp = Nothing
1
Try an absolute path (temporarily). Current working directory is more of an art than a science.Bathsheba
I sometimes run into issues getting the "Excel" application to close. In ASP, this could get real bad. Get on the server and check task manager to see if it is running. Also, while there, see if you can open the file while logged into the server. It might give you an idea of what is happening.Steve
Path seems correct. Yeap can open the fileD-W

1 Answers

1
votes

I found the solution that worked for me. If you open up Component Services (Located under Control Panel >Admin Tools) Computers >My Computer>DCom Config>Microsoft Excel Application, properties, Identity tab, select user.

I created a new new local account to run it under and it all worked.