open NetOffice.ExcelApi
open NetOffice.ExcelApi.Enums
module AddIn =
let mutable private myApp : Application = null
let beforeClose = Application_WorkbookBeforeCloseEventHandler (fun sender e ->
// do something here - sender is the workbook
())
// I call this from my type I define that implements IExcelAddIn
let autoOpen() =
myApp <- new Application (null, ExcelDnaUtil.Application)
myApp.add_WorkbookBeforeCloseEvent beforeClose
1条答案
按热度按时间bihw5rsg1#
通过nuget安装NetOffice Framework:
https://netoffice.io/
现在,在加载项的AutoOpen中,您可以创建一个Application对象,该对象允许您访问所有COM内容,包括事件。
我使用的是F#,而不是C#,但这是我的情况:
字符串