Re: VB.NET and Mail Merge
Yes, but you will need to have Word on your server and mailmerges with templates are tricky. You can use Bookmarks in your template and then just populate them but since your talking a mailmerge are you wanting to populate several documents at once?
Re: VB.NET and Mail Merge
This should give you a basic idea (at least get you on the right track). Write your merge data to a temporary .csv file to use as the data source, and then wipe it when you are done with it. Code is VBA/VB6, and I'll leave you to do the .NET version. sTemplate is the path to the template document, sTempfile is the temp data source.:
VB Code:
Dim oWord As Word.Application, oOut As Word.Document, oMerge As Word.MailMerge, oResult as Word.Document
Set oWord = New Word.Application
Set oOut = oWord.Documents.Add(sTemplate, False, wdNewBlankDocument, False)
Set oMerge = oOut.MailMerge
With oMerge
Call .OpenDataSource(sTempfile)
.Destination = wdSendToNewDocument
.Execute
End With
Set oResult = oWord.ActiveDocument 'This is your merged document.
'Close and release ref'd objects.
Re: VB.NET and Mail Merge
in response to robdog888, i am oly merging to one word document when the submit button is clicked. So one label is created at a time and thus no need for loops or anything.
Does that make it any simpler?
Re: VB.NET and Mail Merge
Yes, so using something like what comintern posted should be good just convert to .net.
Re: VB.NET and Mail Merge
i have no experience of vb6 and have just started with vb.net. Are the syntax's and structures the same. Can anyone help me further with the conversion.
Thanks in advance!