rsmeyerson
Board Regular
- Joined
- Nov 29, 2014
- Messages
- 104
I'm hoping to get some help completing a mail merge using VBA. I have already formatted a word document and added all merge fields from my data source which is an excel sheet named "PaymentDue". I have code that opens my word document, but it does not connect to my data source. When I open the word doc manually, I am prompted by a message box which states "Opening this document will run the following SQL command." By answering "Yes", the data source is connected to the word document. Can someone please help me connect my word document to my data source, and then execute a mail merge?
Here is the code I have which opens my word document:
Here is the code I have which opens my word document:
Code:
Sub Run_Mail_Merge()
Dim wordApp As Object
Set wordApp = CreateObject("Word.Application")
wordApp.Documents.Open Filename:="C:\Users\bmeyerson\Desktop\FICO_Merge.docx"
wordApp.Visible = True
End Sub