简体   繁体   中英

ThisShutdown Event file deletion in Excel addins VSTO using c#

I have Multiple Excel file opened i need to delete the file while closing the file one by one, Shutdown event is trigger in last file that we closing,

Expected behavior: Shutdown Event needs to be triggered while closing the file on by one in Excel add ins VSTO using c#

The Excel object model doesn't provide such events. But you may combine several events to be aware when a workbook is closed.

You can be interested in the Workbook.BeforeClose event which is fired before the workbook closes. If the workbook has been changed, this event occurs before the user is asked to save changes. But you can't be sure the workbook is closed at this stage. You need to track the window associated with this workbook. The Workbook.WindowDeactivate event is fired when a workbook window is deactivated. So, you may treat this workbook as closed. And in this case you can delete the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM