【发布时间】:2020-08-24 11:51:52
【问题描述】:
我有一个 Word 文档,它使用 VBA 表单根据选择框生成文档内容。 VBA 从其他 Word 文档复制并粘贴到主文档中。我使用显式路径来指定它应该去哪里找到单词文档。
改用 UNC 路径会很好,以删除文件位置 (c:\Files\Example\Content\PROFILE.docx) 的一些“明确性”,并可能将其替换为“..\内容\配置文件.docx " 代码示例:
Sub GenerateProfile()
Dim currentPathProfile As String
currentPathProfileText = ActiveDocument.Path
currentPathProfileText = currentPathProfileText & "c:\Files\Example\Content\PROFILE.docx"
Documents.Open FileName:=currentPathProfileText
Dim currentPathProfileDoc As Document
Set currentPathProfileDoc = Documents(1)
currentPathProfileDoc.Activate
Call CopyWholeContent
currentPathProfileDoc.Close
Call PasteWholeContent
End Sub
【问题讨论】:
-
您在询问 UNC 路径,但您似乎在询问 相对路径 ?