c#获取所有打开的Excel文档

时间:2016-08-22 08:06:39

标签: c# excel

我在stuckoverflow中找到了一些代码示例 在这里:Get all opened Excel-documents

并将其用于此:

  foreach (Microsoft.Office.Interop.Excel.Workbook WB in oExcelApp.Workbooks)
            {
                if(WB.Name == filename)
                xlwkbook = WB;
            }

我打开了3个excel文件: enter image description here

每次我打开它们并执行代码,然后我在循环中(在oExcelApp.Workbooks中)有不同数量的excel。

有时我只有 - 2production.xlsm

有时我有 - 2production.xlsm和europe.xlsm

所有人都

每次别的什么。

为什么我不是每次都得到所有这些???

请求帮助。

0 个答案:

没有答案