Word文档是否具有用于呈现动态信息的任何脚本功能?我想要做的是让文档动态地拉入HTML文件的内容,并在每次打开时将其附加到文档的末尾。
有人知道这是否可行?
答案 0 :(得分:2)
将以下内容放入代码模块中。每次打开文档时都会运行AutoOpen
例程。
Public Sub AutoOpen()
Dim currentDocument As Document
Set currentDocument = ActiveDocument
Dim sourceDocument As Document
Set sourceDocument = Application.Documents.Open(FileName:="e:\mySourceName.docx")
sourceDocument.Range.Copy
sourceDocument.Close wdDoNotSaveChanges
Set sourceDocument = Nothing
Dim pasteRange As Range
Set pasteRange = currentDocument.Range
pasteRange.Collapse wdCollapseEnd
pasteRange.Paste
End Sub