mail merge RRS feed

  • Question

  • User-891401704 posted

    How to call mailmerge function in asp.net

    Sunday, October 11, 2009 10:31 PM

All replies

  • User-1659704165 posted



    have u chked the above link

    Monday, October 12, 2009 12:18 AM
  • User-891401704 posted



    Can u show me code in vb.net? 

    Monday, October 12, 2009 4:11 AM
  • User-1659704165 posted

    downlaod trhe code from source..
    and U may convert Code form csharp.to  VB using Below link


    Monday, October 12, 2009 5:01 AM
  • User-891401704 posted


    This code is convert already.  But is it this code inside Window Form. Can i ask u, win Form & Web Application the code is it same?...


    Monday, October 12, 2009 5:38 AM
  • User-891401704 posted

    What i'm trying to do is when user click 1 button on their system.  Will go to word form. In the word form user can define  field they want to show.  That means system will declare what database to use.  (Insert fields able to choose).  Below is my code

     Private Sub CreateMailMergeDataFile()
            Dim wrdDataDoc As Word._Document
            Dim iCount As Integer
            Dim sDBPath As String
          ' Create a data source at C:\ApplicationFormI.doc containing the field data.
            wrdDoc.MailMerge.CreateDataSource(Name:="C:\ApplicationFormV.doc", _
           ' Open the file to insert data.
            wrdDataDoc = wrdApp.Documents.Open("C:\ApplicationFormV.doc")
           For iCount = 1 To 2
            Next iCount
            ' Fill in the data.
            FillRow(wrdDataDoc, 2, txtName.Text, txtPassport.Text, "F.600 Jalan Tanjung", "Johor Bahru, MALAYSIA")
            ' Save and close the file.
        End Sub
     Protected Sub BtnPrintYatie_Click(ByVal sender As Object, ByVal e As EventArgs) Handles BtnPrintYatie.Click
               Dim wrdSelection As Word.Selection
            ' Dim wrdSelectionBold As Word.Selection
            Dim wrdMailMerge As Word.MailMerge
            Dim wrdMergeFields As Word.MailMergeFields
            Dim StrToAdd As String
            'Dim StrToAddComname 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.Add()
            wrdSelection = wrdApp.Selection()
            wrdMailMerge = wrdDoc.MailMerge()
            ' Create MailMerge Data file.
            '' Go to the end of the document.
            wrdApp.Selection.GoTo(Word.WdGoToItem.wdGoToLine, _
            ' Perform mail merge.
            wrdMailMerge.Destination = _
            ' Close the original form document.
            wrdDoc.Saved = True
            ' Release References.
            wrdSelection = Nothing
            wrdMailMerge = Nothing
            wrdMergeFields = Nothing
            wrdDoc = Nothing
            wrdApp = Nothing
            ' Clean up temp file.
        End Sub


    if u see my code, i'm using createdatasource --> go to my word file.  But i tried to use database from sql.  But don;t know.  Anybody can help me?

    Monday, October 12, 2009 9:52 PM