手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

VBA中BeforeClose事件的使用

时间:2024-10-12 00:43:26

1、打开excle的表格,进入VBA的编程界面,在列表中选择workbook

VBA中BeforeClose事件的使用

2、然后为这个程序写上注释内容。

VBA中BeforeClose事件的使用

3、新建一个BeforeClose事件,这个事件表示的是在工作薄关闭之前所触发的事件。Private Sub Workbook_BeforeClose(Cancel As Boolean)End Sub

VBA中BeforeClose事件的使用

4、然后定义一个变量intreturnDim intreturn As Integer

VBA中BeforeClose事件的使用

5、用msgbox函数来输出相关的内容。intreturn = MsgBox("你真的要退出来了吗?", vbYesNo + vbQuestion, "小提示")

VBA中BeforeClose事件的使用

6、如果intreturn的值不等于vbYes,就不选择退出工作薄。

VBA中BeforeClose事件的使用

7、最后运行这个程序即可。

VBA中BeforeClose事件的使用
© 手抄报圈