在VBA中找不到Workbook_BeforeClose函数

我正在试图在这里遵循这个教程 。 我无法在Mac中findWorkbook_BeforeClose函数。 但似乎无法find它。

屏幕截图如下所示: 在这里输入图像说明

这不在列表中。 我如何激活它?

任何想法我怎么能find它?

我无法在Mac中findWorkbook_BeforeClose函数

呃…那是因为你看错了地方? 您必须在工作簿模块中,而不是工作表模块。

看截图

在这里输入图像说明

你可以这样编码:

Private Sub Workbook_BeforeClose(Cancel As Boolean) 'ThisWorkbook Module code! ActiveWorkbook.Save 'Me.Save is safer - if this workbook is closed programmatically 'then ActiveWorkbook may not be the same one End Sub 

请看Excel先生:
http://www.mrexcel.com/forum/excel-questions/170240-visual-basic-applications-before-close-save-workbook.html

也:
Workbook.BeforeClose事件(Excel):
http://msdn.microsoft.com/en-us/library/office/ff194765.aspx