I create application by c# is "Lab Connects".It use to open excel file already exists, modify, and save. But it occur error :
System.Runtime.InteropServices.COMException (0x800A03EC): Excel cannot access 'Lab Connects'. The document may be read-only or encrypted. 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)
This is code :
Excel.Application excel = new Excel.Application();
Excel.Workbook workbook = excel.Workbooks.Open(filePath);
Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Sheets.get_Item(1);
workbook.Save();
workbook.Close();
Note : Excel file has Macro. Hope there's a solution from everyone !
What I have tried:
- I was set for user is full permission (Administrator)
- I was update excel file from .xls to .xlsx and .xlsm(Excel use Macro)
=> But all is not work