AZshooter
asked on
Need to export data from Excel 2013 into a Word Doc (Mail Merge) that is based upon an existing .dotx template
I am having trouble getting this to work. I need to make sure I am late-binding objects due to compatibility issues with various Office versions being used by coworkers.
I have an existing .dotx Word template that needs to be used as the basis for the final document. The data is coming from an SQL query of the Excel sheet.
I am finding most of my issues are with the Word aspect. It has to do with whether Word is already running or not, or if there is an open document or not.
Thanks in advance.
I have an existing .dotx Word template that needs to be used as the basis for the final document. The data is coming from an SQL query of the Excel sheet.
I am finding most of my issues are with the Word aspect. It has to do with whether Word is already running or not, or if there is an open document or not.
Thanks in advance.
ASKER
Hello. Thank you for the reply.
Yes, I am looking for the means to do this with a VBA macro in Excel 2013. The workbook stores the inventory of our demo equipment. When a sales-person wants to check it out he prints a request which get populated with the details for a worksheet.
So, in VBA I want to create a new Word document based upon an existing template. Then do the mailmerge with the data from the spreadsheet.
Where I seem to be having problems I think is the new SDI of Office 2013, it used to work very well in 2010. Also, I am trying to late-bind objects in my code now because of variations of Office versions within our group. So, losing IntelliSense probably led to me getting stuff wrong...I'm not that great a programmer.
When this part of my code runs:
Set wdApp = CreateObject("Word.Applica tion")
Set wdocSource = wdApp.documents.Add(templa te:=WordTe mplatePath )
Word does not start, nor does a new document get created.
I hope I'm explaining myself clearly.
Thank in advance.
Yes, I am looking for the means to do this with a VBA macro in Excel 2013. The workbook stores the inventory of our demo equipment. When a sales-person wants to check it out he prints a request which get populated with the details for a worksheet.
So, in VBA I want to create a new Word document based upon an existing template. Then do the mailmerge with the data from the spreadsheet.
Where I seem to be having problems I think is the new SDI of Office 2013, it used to work very well in 2010. Also, I am trying to late-bind objects in my code now because of variations of Office versions within our group. So, losing IntelliSense probably led to me getting stuff wrong...I'm not that great a programmer.
When this part of my code runs:
Set wdApp = CreateObject("Word.Applica
Set wdocSource = wdApp.documents.Add(templa
Word does not start, nor does a new document get created.
I hope I'm explaining myself clearly.
Thank in advance.
ASKER
Here is my solution:
Set wdApp = CreateObject("Word.Applica tion")
wdApp.Visible = True
Set wdocSource = wdApp.documents.Add(templa te:=WordTe mplatePath ) 'e.g. "R:\demo\public\EVT_DERF_C atalog.dot x"
wdocSource.Visible = True
Looks like this works for me.
Set wdApp = CreateObject("Word.Applica
wdApp.Visible = True
Set wdocSource = wdApp.documents.Add(templa
wdocSource.Visible = True
Looks like this works for me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
With it open in Word, you click on the Finish & Merge button on the Mailings tab, and the merge takes place.
Are you doing something different? If so what - and what exactly goes wrong>