How to get Excel VBA code to trigger Word Mail Merge

85 Views Asked by At

I have an Excel file that is used to populate a Word document via mail merge. When I open the Word document, it reacts properly and a Message Box appears stating: enter image description here PERFECT!!

But, when I created a button in Excel to open this Word Document, I cannot get it to trigger the Mail Merge.

Here is the code in my Excel document for the button I've created.

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

That code opens the document, but I just get the original data, no update or trigger to update with mail merge.

What do I need to change here?

Thank you!!!

0

There are 0 best solutions below