I need create xls-file with own data. But file may already be created, and opened by user.
(1) If file not exist: new ApplicationClass() Workbooks.Add() SaveAs()...
I know is late to answer you, but may be useful to someone else.
Microsoft.Office.Interop.Excel.Application oExcelApp;
oExcelApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
foreach (Microsoft.Office.Interop.Excel.Workbook WB in oExcelApp.Workbooks) {
MessageBox.Show(WB.FullName);
}
oExcelApp = null;