保存事件后触发MS Word宏 [英] Trigger MS Word macro after save event

查看:112
本文介绍了保存事件后触发MS Word宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MS Word 2007模板的页脚中带有文件名.用户将打开模板并执行另存为..."以制作其文档.

My MS Word 2007 template has a footer with the filename in it. The user is going to open the template and do a "Save As..." to make their document.

我希望页脚中显示的文件名立即更新为新文件名.

I want the filename shown in the footer to update immediately to the new filename.

是否存在AfterSaveEvent或可用作挂钩来启动我的VBA脚本的东西?

Is there an AfterSaveEvent or something that I can use as a hook to start my VBA script that does the update?

还是有更简单的方法?

推荐答案

只需创建一个这样的宏(我相信,如果将它包含在Normal.dot中,效果会更好)

Just create a macro like this (I believe it works better if included in the Normal.dot)

Sub FileSaveAs()
'
' FileSaveAs Macro
' Saves a copy of the document in a separate file
'
Dialogs(wdDialogFileSaveAs).Show

'returns the name including the .doc extension 
 ChosenFileNameAndExtension = ActiveDocument.Name 'Or use .FullName

' Your code here

End Sub

只要用户选择文件另存为",便会触发该事件.

It will be triggered whenever the user selects "File Save As"

HTH!

这篇关于保存事件后触发MS Word宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆