Skip to main content
March 23, 2007
Answered

Creating mail merge application using Word

  • March 23, 2007
  • 2 replies
  • 1674 views
Hi,

We are in the process in developing a coldfusion web application that enables user to upload Word document and a data source for mail merge.

After spending few hours googling, we are still unable to find a definite solution. Does anyone give us a pointer on how we might be able to achieve this? Can coldfusion maybe by using Java be able to access Microsoft's Office objects?

Your help will be truly appreciated.
This topic has been closed for replies.
Correct answer
Use the <cfobject> tag of coldfusion to create the below objects of word application (you should have Microsoft word installed in your cf server).
Word.Application
Word.Document
Word.MailMerge

Then you can follow the same steps how you do a VB program to create the Word MailMerge in ColdFusion. A sample vb code is give below,

Dim oWordApp As New Word.Application
Dim WrdDoc As Word.Document
Dim wrdMailMerge As Word.MailMerge

Set WrdDoc = oWordApp.Documents.Open("template path", ReadOnly:=True)
Set wrdMailMerge = WrdDoc.MailMerge
wrdMailMerge.OpenDataSource Name:="file path", Format:="format", ConfirmConversions:=True
wrdMailMerge.Destination = wdSendToNewDocument
wrdMailMerge.Execute
oWordApp.ActiveDocument.SaveAs FileName:="full path & name", FileFormat:="format"

Set oWordApp = Nothing

2 replies

March 26, 2007
Thanks for your help, I will try to implement your suggestion.
Correct answer
March 23, 2007
Use the <cfobject> tag of coldfusion to create the below objects of word application (you should have Microsoft word installed in your cf server).
Word.Application
Word.Document
Word.MailMerge

Then you can follow the same steps how you do a VB program to create the Word MailMerge in ColdFusion. A sample vb code is give below,

Dim oWordApp As New Word.Application
Dim WrdDoc As Word.Document
Dim wrdMailMerge As Word.MailMerge

Set WrdDoc = oWordApp.Documents.Open("template path", ReadOnly:=True)
Set wrdMailMerge = WrdDoc.MailMerge
wrdMailMerge.OpenDataSource Name:="file path", Format:="format", ConfirmConversions:=True
wrdMailMerge.Destination = wdSendToNewDocument
wrdMailMerge.Execute
oWordApp.ActiveDocument.SaveAs FileName:="full path & name", FileFormat:="format"

Set oWordApp = Nothing