C# Excel Addin - Get the active excel workbook

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 08:58:37

问题


I am writing an excel Add which will fetch data from database. I am able to add the custom menu to excel in OnConnection Extensibility.IDTExtensibility2, but after that the Excel Object is destroyed and I am not able to access the Active Workbook.

How to access the excel workbook that is active?


回答1:


1>((Microsoft.Office.Interop.Excel.Application)Marshal.GetActiveObject("Excel.Application").ActiveWorkBook
2>You can check my answer here to get handle to excel application object Get the excel cell address from a UDF



来源:https://stackoverflow.com/questions/8738314/c-sharp-excel-addin-get-the-active-excel-workbook

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!