Run an Excel-to-Word Mail Merge with VBA and DDE
Question details
Use Excel VBA to open a copied Word document and connect an Excel worksheet as its mail merge data source.

- Product
- Microsoft Excel and Microsoft Word
- Device & OS
- not provided
- Scenario
- An Excel macro needs to run a Word mail merge using records from the Data worksheet.
- Observed behavior
- The Word document should connect to the intended worksheet and use its rows as mail merge records.
Save the Excel workbook, confirm that the worksheet is named Data, and make sure its first row contains merge field names. Prepare a copied Word document with merge fields and note its full file path; DDE availability depends on the Office environment and security settings.
Connect the Excel Data worksheet to Word with VBA
Use this approach to open a copied Word document from Excel and select its Data worksheet as the merge source.
The example uses late binding, so it does not require a Word object-library reference in the VBA editor. It requests a conversion prompt where available; DDE is not guaranteed to be offered or permitted.
In Excel, press Alt+F11, then choose Insert > Module in the VBA editor.
Paste the following code into the module and replace the Word document path with the path to your copied document: Sub MergeExcelDataToWord() Dim wordApp As Object Dim wordDoc As Object Dim wordPath As String wordPath = "C:\Path\CopiedTemplate.docx" Set wordApp = CreateObject("Word.Application") wordApp.Visible = True Set wordDoc = wordApp.Documents.Open(wordPath) With wordDoc.MailMerge .OpenDataSource Name:=ThisWorkbook.FullName, _ ConfirmConversions:=True, _ Connection:="Entire Spreadsheet", _ SQLStatement:="SELECT * FROM `Data$`" .Destination = 0 ' Send to a new document .Execute Pause:=False End With End Sub
Run MergeExcelDataToWord from the VBA editor. If Word displays a data-source conversion dialog and offers Excel via DDE, select it; then check the generated document for the expected records.
If your sheet has a different name, change `Data$` in SQLStatement to the exact worksheet name followed by a dollar sign, keeping the backticks around it.

Work with Excel and Word files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with spreadsheets and documents. Its Microsoft Office format compatibility helps you move existing files into your workflow, although it does not fix Microsoft Office DDE settings or guarantee compatibility with this VBA macro.

Frequently Asked Questions
How do I select a different worksheet for the merge?
In the macro's SQLStatement, replace `Data$` with the exact sheet name followed by a dollar sign. For example, use SELECT * FROM `Customers$` for a sheet named Customers.
Why doesn't Word offer DDE when the macro runs?
DDE may be unavailable or restricted by the Office installation or security policy. Check the available conversion options and your organization's Office security settings, or test a supported alternative data-source method.
Do I need to add a Word reference in the VBA editor?
Not for the example above. It uses CreateObject and declares Word objects as Object, so it can run without selecting a Word object library under Tools > References.
Where does the merged output appear?
The macro sets MailMerge.Destination to 0, which sends the merged records to a new Word document. The copied source document remains open in Word.




