View Single Post
Old 08-09-2018, 01:43 PM
stevenel stevenel is offline Windows 7 64bit Office 2013
Join Date: Jul 2018
Posts: 26
stevenel is on a distinguished road
Default Mailmerge Excel with a Master Word Template (via VBA)

Hey guys,

I currently have two files. One is my excel with data in it. One is my word (which I call my master) where you can find all my mergefields. Instead of opening word every time, choosing the excel location then printing it out, I wanna code it via VBA. Here's my code:

Public Sub Print()

Set wDApp = CreateObject("Word.Application")

wDApp.Documents.Open (blablabla)

With wdApp.MailMerge
.MainDocumentType = wdDirectory
LinkToSource=True, AddToRecentFiles, _
End With

End Sub

My first question is regarding blablabla2. How do I code it so VBA knows I want him to use the current workbook i am currently on (my workbook has only one worksheet). My second question is how do I make the code working? I know it doesn't end there and it crashes so any help would be appreciated

thank you very much in advance
Reply With Quote