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.
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).