Excel Macro causes Mail Merge in word to crash.

JedStarkiller

New Member
Joined
Jun 19, 2017
Messages
2
Hey Excel Guru's! I could use some help. I am trying to automate a process we have several letters we send out and I am trying to make it where we can just select the people and letter. I am just working on automating the mail merge feed from Excel. When I do the merge via Word manually it works fine. However when I try to run the following macro Word will crash if you try to click through the created pages, or if you try to select the edit recipients options. Is there something in the code causing this?

Code:
Sub OPENWORD()Dim Bottom As Long


Set appWd = CreateObject("Word.Application")
appWd.Visible = True
 
appWd.Documents.Open Filename:="C:\Term Project\Termed EE - Retirement Only Letter.docx"


appWd.ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
appWd.ActiveDocument.MailMerge.OpenDataSource Name:= _
        "C:\Term Project\2017 Termination Lists-DWH.xlsm", _
        ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
        AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
        WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
        Format:=wdOpenFormatAuto, Connection:= _
        "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=C:\Term Project\2017 Termination Lists-DWH.xlsm;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engine Type=35;Jet OLE" _
        , SQLStatement:="SELECT * FROM `'CURRENT TERM LIST$'` where `EE ID #` is not NULL", SQLStatement1:="" _
        , SubType:=wdMergeSubTypeAccess


appWd.ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle


End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top