请问:如何取得word点击保存时的事件,当点击word的保存时,word能执行我编写的代码

markparton 2004-03-22 05:19:23
请问:word保存的事件是什么(如关闭的是Private Sub ObjApp_DocumentBeforeClose(ByVal Doc As Word.Document, Cancel As Boolean)
...全文
44 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
markparton 2004-03-23
  • 打赏
  • 举报
回复
Private WithEvents ObjApp As Word.Application
Private Sub ObjApp_DocumentBeforeSave(ByVal Doc As Document, ByVal SaveAsUI As Boolean, ByVal Cancel As Boolean)

我如此写它报错了
"过程声明与同名事件或过程的描述不匹配"
markparton 2004-03-23
  • 打赏
  • 举报
回复
DocumentBeforeSave事件
具体怎么用,包括声明等
vansoft 2004-03-23
  • 打赏
  • 举报
回复
同意楼上的
TechnoFantasy 2004-03-22
  • 打赏
  • 举报
回复
DocumentBeforeSave事件
My97 2004-03-22
  • 打赏
  • 举报
回复
首先用 filedatetime 函数取得目标word文件的日期

在配合一个定时器(interval=500)就可以实现




const docfile="c:\aa.doc"
date1=filedatetime(docfile)

Private Sub Timer1_Timer()
if filedatetime(docfile)>date1 then '说明目标文件比原来文件更新
'执行你的代码
end if
End Sub

//老兄我可是写得很辛苦哦,一定要好好看看这段代码.
Tomtop 2004-03-22
  • 打赏
  • 举报
回复
在Document的CLOSE事件中编写即可.
Document_Close()

End Sub

2,462

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧