1、类模块中创建名为AppEventHandle的对象,属性选择2 - PublicNotCreateable
'文档关前操作
Private Sub app_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
intResponse = MsgBox("是否将更改保存到“"+Doc.Name+"”中?", vbYesNoCancel)
'取消关闭文档
If ThisDocument.intResponse = vbCancel Then
Cancel = True
End If
'保存并关闭文档
If ThisDocument.intResponse = vbYes Then
ActiveDocument.Close wdSaveChanges
End If
'不保存文档并关闭文档
If ThisDocument.intResponse = vbNo Then
ActiveDocument.Close wdDontSaveChanges
End If
End Sub
2、ThisDocument
添加全局变量
Public intResponse As Integer '用来接收关闭时选择的操作的参数值
Public app As New AppEventHandle
'注册Applicant事件
Sub Register_Event_Handler()
On Error Resume Next
Set app.app = Application
End Sub
3、Document_Close方法中处理代码去掉
本文来源:https://www.wddqw.com/doc/491dae069b6648d7c0c74635.html
正在阅读:
VBA禁用Word自带保存提示处理方法(个人总结)01-01
清明唐杜牧古诗01-01
史上最全的3ds max及vray资源(种子)渲染教程全集打包下载01-01
又是一年粽子飘香时高三作文01-01
绘画主题01-01
互联网金融征信体系的野蛮生长01-01
最新读书笔记好词好句01-01
微博对我们生活方式的影响01-01