VBA保存时更新文件名和路径 [英] VBA update filename and path upon saving
本文介绍了VBA保存时更新文件名和路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用下面的以下代码,但是没有一个会给我一个活动字段,该字段在保存时会更新. 我想要文件路径和名称.也许你可以帮忙.谢谢.
I've tried using the following codes below, but none will give me an active field that will update upon saving. I want the file path and name. Maybe you can help. Thanks.
ActiveDocument.Name
-给出文档名称,不包含路径信息.
ActiveDocument.Name
- gives the name of the document, without path information.
推荐答案
正如@braX所说
使用FullName
获取文件名和路径.
注意FullName
仅在保存文档一次之后包含文件路径!
Use FullName
to get the file name and path.
Note FullName
will only contain the file path AFTER you have saved the document once!
' Saved
ActiveDocument.FullName ' -> C:\Documents\Doc1.docx
' Unsaved
ActiveDocument.FullName ' -> Document2
使用Name
仅获取文件名
ActiveDocument.Name ' -> Doc1.docx
这篇关于VBA保存时更新文件名和路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文