VBA & Macro Problems

Run an Excel-to-Word Mail Merge with VBA and DDE

Huda QurayshiHuda Qurayshi Nov 20, 2026 869 views

Question details

Use Excel VBA to open a copied Word document and connect an Excel worksheet as its mail merge data source.

Run an Excel-to-Word Mail Merge with VBA and DDE
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

In Excel, press Alt+F11, then choose Insert > Module in the VBA editor.

2
Add the merge macro

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

3
Run and check the merge

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.

4
Verify the worksheet name

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.

Connect the Excel Data worksheet to Word with VBA
DDE support varies: The Entire Spreadsheet connection and SQL worksheet selection may behave differently across data-source methods. If DDE is unavailable or the connection fails, check current Word and Excel security settings and test another supported data-source method. Do not weaken organizational security settings without approval.
Free Microsoft Office alternative

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.

Work with spreadsheet data and document layouts in one office suiteOpen and edit Microsoft Excel and Word formats, including XLSX and DOCXUse a familiar interface to ease migration from Microsoft OfficeGet a free, lightweight office alternative
QA img-9

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.