Mail Merge with VB.net

jsurprenant

Newcomer
Joined
Oct 1, 2003
Messages
1
Hi

I am writing an VB.net Mail Merge application. I have a series of templates which reside on my machine. I am trying to use eith a dataset, datatable or dataview as my datasource.

Here is my sample code:
Dim strFileWithPath As String = "c:\jax.doc"
Dim wrdApp As Word.Application
Dim wrdDoc As Word._Document
Dim wrdMailMerge As Word.MailMerge
dim dvCompany as New DataView

wrdApp = CreateObject("Word.Application")
wrdDoc = wrdApp.Documents.Open(FileName:=strFileWithPath)
wrdMailMerge = wrdDoc.MailMerge()
'dvCompany contains some data from earlier in the program
wrdMailMerge.DataSource = dvCompany

wrdApp.Visible = True
wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
wrdMailMerge.Execute(Pause:=False)

I get an error at "wrdMailMerge.DataSource = dvCompany" - saying that the property is readonly

I need to be able to populate my template with the data in the datview, so how do I do this? The only examples I have seen on the web is using email in ASP.net. I want to do this to a Word Document using VB.net.

Any ideas?

Regards

Jackie
 
Back
Top