Mail Merge

  • Thread starter Thread starter Jackie
  • Start date Start date
J

Jackie

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 either 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