VBA update filename and path upon saving

折月煮酒 提交于 2019-12-25 09:36:16

问题


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 - gives the name of the document, without path information.


回答1:


As @braX says

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

use Name to get the file name only

ActiveDocument.Name ' -> Doc1.docx


来源:https://stackoverflow.com/questions/45356821/vba-update-filename-and-path-upon-saving

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!