我有一个 Excel 文件,用于通过邮件合并填充 Word 文档。 当我打开 Word 文档时,它反应正常,并出现一个消息框,指出: 完美!!
但是,当我在 Excel 中创建一个按钮来打开此 Word 文档时,我无法让它触发邮件合并。
这是我创建的按钮在 Excel 文档中的代码。
Private Sub cmbPrintWarranty_Click()
Dim WordApp As Object
Dim WordDoc As Object
' Get the Word application
On Error Resume Next
Set WordApp = GetObject(Class:="Word.Application")
If WordApp Is Nothing Then
Set WordApp = CreateObject(Class:="Word.Application")
End If
On Error GoTo 0
WordApp.Visible = True
' Get the active document
Set WordDoc = WordApp.Documents.Open _
("C:\Users\User1\OneDrive - User1\Documents\Projects Open\zzWarranty.docx")
End Sub
该代码打开文档,但我只获取原始数据,没有更新或触发通过邮件合并进行更新。
我需要在这里更改什么?
谢谢!!!
请参阅上面的评论。
@June7 回答了。