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

查看:25
本文介绍了保存事件后触发 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?

或者有更简单的方法吗?

Or is there a much easier way?

推荐答案

只需创建一个这样的宏(我相信如果包含在 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天全站免登陆