在VBA中找不到Workbook_BeforeClose函数

时间:2013-07-07 13:25:55

标签: excel excel-vba-mac

我想在这里关注Tutorial。我在Mac上找不到Workbook_BeforeClose函数。但似乎无法找到它。

屏幕截图如下所示:enter image description here

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

知道我怎么能找到它吗?

2 个答案:

答案 0 :(得分:3)

你可以这样编码:

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

答案 1 :(得分:3)

  

我在Mac上找不到Workbook_BeforeClose函数

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

见截图

enter image description here