简体   繁体   English

ThisShutdown 事件文件删除 Excel 使用 c# 插件 VSTO

[英]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,我打开了多个 Excel 文件我需要在关闭文件的同时删除文件,关闭事件是在我们关闭的最后一个文件中触发,

Expected behavior: Shutdown Event needs to be triggered while closing the file on by one in Excel add ins VSTO using c#预期的行为:在 Excel 使用 c# 添加 VSTO 中的文件时需要触发关闭事件

The Excel object model doesn't provide such events. Excel object model 不提供此类事件。 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.您可能会对在工作簿关闭之前触发的Workbook.BeforeClose事件感兴趣。 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.您需要跟踪与此工作簿关联的 window。 The Workbook.WindowDeactivate event is fired when a workbook window is deactivated.当工作簿 window 被停用时,会触发Workbook.WindowDeactivate事件。 So, you may treat this workbook as closed.因此,您可以将此工作簿视为已关闭。 And in this case you can delete the file.在这种情况下,您可以删除该文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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