Get all opened Excel-documents

前端 未结 1 1497
春和景丽
春和景丽 2021-01-23 16:18

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()...

1条回答
  •  爱一瞬间的悲伤
    2021-01-23 16:40

    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;
    

    0 讨论(0)
提交回复
热议问题