|
-
Jul 18th, 2006, 10:33 AM
#1
Thread Starter
Member
VB.NET and Mail Merge
Hello,
I wish to link my vb.net web application to word 2003 mail-merge function.
What i specifically wish to do is have a form with some static textboxes and some dropdown lists. Then have a button called create label. When the user clicks this, the method links to a word template with mail merge fields and those fields are populated with the information on the web-form to create a label.
Can this be done and how?
Your help is much appreciated!
-
Jul 18th, 2006, 10:37 AM
#2
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?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 18th, 2006, 11:17 AM
#3
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.
-
Jul 19th, 2006, 11:03 AM
#4
Thread Starter
Member
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?
-
Jul 19th, 2006, 11:31 AM
#5
Re: VB.NET and Mail Merge
Yes, so using something like what comintern posted should be good just convert to .net.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 19th, 2006, 01:16 PM
#6
Thread Starter
Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|