Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 22nd, 2005, 02:56 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Word Mail Merge Automation using ASP.Net

Hi,

I am trying to automate word mail merge and redirecting the output to the printer. Since I am making use of ASP.Net as technology, so word application is not visible to me. But when print command fires from the code, a print dialog box opens up in the background, which makes the system to hang. Please do the needful.


Dim wrdSelection As Word.Selection
        Dim wrdMailMerge As Word.MailMerge
        Dim wrdMergeFields As Word.MailMergeFields

        Dim StrToAdd As String

        ' Create an instance of Word and make it visible.
        wrdApp = CreateObject("Word.Application")
        wrdApp.Visible = True
        wrdApp.DisplayAlerts = 0

        ' Add a new document.

        wrdDoc = wrdApp.Documents.Open("ThankYou.doc")
        wrdDoc.Select()

        wrdSelection = wrdApp.Selection()
        wrdMailMerge = wrdDoc.MailMerge()

        ' Create MailMerge Data file.
        CreateMailMergeDataFile()

        Dim strPrinterName As String
        Dim objDialog As Object
        strPrinterName = wrdApp.ActivePrinter

        wrdApp.ActivePrinter = "Dummy"
        wrdMailMerge.SuppressBlankLines = True

        wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter

        wrdMailMerge.Execute(False)
        wrdApp.ActivePrinter = strPrinterName


        ' Release References.
        wrdSelection = Nothing
        wrdMailMerge = Nothing
        wrdMergeFields = Nothing
        wrdDoc = Nothing
        wrdApp = Nothing


  #2 (permalink)  
Old April 28th, 2006, 11:41 PM
Registered User
 
Join Date: Apr 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Did you solve this problem in the end? I'd be interested to know the solution.

Cheers


n
  #3 (permalink)  
Old December 17th, 2007, 02:13 AM
Registered User
 
Join Date: Dec 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi i want to do the mail merge using a mSword template and CSV file and save the resulting document as PDF.How can i do that .Please advice me .

Thanks.

  #4 (permalink)  
Old November 29th, 2013, 07:18 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2013
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Word Mail Merge Automation

Hi, I also encountered some issues when I used a .NET word interop in ASP.NET app.
I found that it is not supported: MS support page (Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications on server side), but they provide some alternatives to server-side automation.
You could try this alternative VB.NET Word component to achieve mail merge in .NET from the server side, here is a small example:
Code:
' Load DOC document.
Dim document = DocumentModel.Load("ThankYou.doc")

' Execute mail merge.
document.MailMerge.Execute(dataSource)
Also you could easily print Word with .NET without PrintDialog popping out, just use this:
Code:
document.Print()
Additionally, aditya_raj you can also check this out because I found its mail merge process to be very flexible and customizable.
You could for example read CSV file into a DataTable and then use it as an data source for a mail merge execution, after which you could convert Word file to a PDF in .NET like the following:
Code:
document.Save("Document.pdf")
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access launching Word for mail merge Loralee Access 8 November 14th, 2005 04:24 PM
Mail Merge with MS Word bezaman Classic ASP Basics 1 October 6th, 2005 05:13 PM
Access to Word Mail Merge Automation kareltje Access VBA 6 June 9th, 2005 05:54 AM
Wrap Up feature (like Word Mail Merge) jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 June 28th, 2004 04:20 PM
Use ASP to create Mail Merge in Ms Word eapsokha Classic ASP Professional 3 March 9th, 2004 07:45 PM



All times are GMT -4. The time now is 07:28 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.