0

I am trying to run this code as SharePoint solution. When I deploy it, it gets stuck on trying to open excel file:most likely, solution does not have an access. When I try to run the same code in console application, when opening a workbook, the console app asks for username and password.

string fileName = "http://spserver/sites/dev2/Style%20Library/BookRefresh.xlsx";
var excel = new Microsoft.Office.Interop.Excel.Application();
excel.DisplayAlerts = false;
Workbook theWorkbook = excel.Workbooks.Open(fileName);

please, do you have an idea how I can get a permission to access this file in sharepoint solution? thank you

this is the error:

System.Runtime.InteropServices.COMException was unhandled by user code
  HelpLink=xlmain11.chm
  HResult=-2146827284
  Message=Microsoft Excel cannot access the file 'http://spserver/sites/dev2/Style Library/BookRefresh.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.

Pedro
  • 193
  • 1
  • 7
  • has the sharepoint location been mapped to the network? In order to open files directly on sharepoint, the location has to be mapped to the network drive. – Scott Holtzman Jan 25 '16 at 15:25
  • Hi Scott, yet it has been. Console application opens and updates excel. The problem is, when I use the same code in sharepoint solution and deploy it. This sharepoint solution seems it does not have an access to modify this excel, and I cannot figure out how to give this solution an acceess. – Pedro Jan 25 '16 at 15:29
  • sorry, just double-checking, for clarity sake. So you can go into a windows explorer folder location and click the file and open it manually (outside of code)? – Scott Holtzman Jan 25 '16 at 15:36
  • yes I can. in fact, this is just a dev server and I am a full admin :) – Pedro Jan 25 '16 at 15:38

0 Answers0