mailmerge with web application

asp.net United States
  • 17 years ago

    Hi!
    I'm tring to make a mailmerge in word with visual studio.net.
    I do it with a windows application, but i want create a web form in a web application. How can i do it?
    This is the code of the windows form:


    Private Sub Button1_Click(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles Button1.Click
           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


           ' Add a new document.


           wrdDoc = wrdApp.Documents.Open("C:\Documents and Settings\gio\My Documents\Primo campo.doc")
           wrdDoc.Select()


           wrdSelection = wrdApp.Selection()
           'wrdDoc.MailMerge.DataSource.QueryString = "select * from 'banche' where ididc=3"
           wrdDoc.MailMerge.DataSource.QueryString = wrdDoc.MailMerge.DataSource.QueryString & " where banche.ididc=3"
           wrdMailMerge = wrdDoc.MailMerge()


           ' Perform mail merge.


           wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
           'wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToPrinter


           wrdMailMerge.Execute(False)



           ' Close the original form document.
           'wrdDoc.Saved = True
           'wrdDoc.Select()
           wrdDoc.Close(False)


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


           ' Clean up temp file.
           ' System.IO.File.Delete("C:\DataDoc.doc")
       End Sub




    If i put it in a web form the system give me this error:
    Cannot create ActiveX component.

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If debugging is the process of removing software bugs, then programming must be the process of putting them in.” - Edsger Dijkstra