Hi,
Thanks for the reply. I will explain my exact requriement.
I am having one template in word document and I merged the fields in the document.
For ex, If I have 3 records, Three paragraph will come. for each and every record I will get one paragraph continiously. At the end the document, ie) after 3 rd paragraph, I want to display my table details using merge.
If I am executing the code above, I am getting the merged records for each and every page. But I want to display it only at the end of the document. I attached my output for the above code.
Please help me.
doc.MailMerge.ExecuteWithRegions(Gettables2())
doc.MailMerge.ExecuteWithRegions(Gettables3())
doc.MailMerge.ExecuteWithRegions(Gettable(k))
Private Function Gettable(ByVal i As ArrayList) As DataTable
Dim dt As New DataTable
Dim dr As DataRow
Dim j As Integer
dt.TableName = "TBL"
dt.Columns.Add("Col")
For Each Val As String In i
dr = dt.NewRow()
Dim myControl1 As Control = FindControl("txt" & Val)
If Not myControl1 Is Nothing Then
Dim txtctrl As TextBox = myControl1
dt.Rows.Add(New Object() {txtctrl.Text})
End If
Next
Return dt
End Function
Private Function Gettables2() As DataTable
Dim dt As New DataTable
dt.TableName = "T1"
dt.Columns.Add("Y1")
dt.Columns.Add("R1")
'dt.Columns.Add("ID")
Dim dr As DataRow
dr = dt.NewRow()
dt.Rows.Add(New Object() {Textbox1.Text, Textbox3.Text})
dt.Rows.Add(New Object() {Textbox6.Text, Textbox4.Text})
dt.Rows.Add(New Object() {Textbox11.Text, Textbox5.Text})
dt.Rows.Add(New Object() {Textbox16.Text, Textbox7.Text})
dt.Rows.Add(New Object() {Textbox2.Text, Textbox8.Text})
Return dt
End Function
Private Function Gettables3() As DataTable
Dim dt As New DataTable
dt.TableName = "T2"
dt.Columns.Add("Y2")
dt.Columns.Add("R2")
'dt.Columns.Add("ID")
Dim dr As DataRow
dr = dt.NewRow()
dt.Rows.Add(New Object() {Textbox9.Text, Textbox10.Text})
dt.Rows.Add(New Object() {Textbox12.Text, Textbox13.Text})
dt.Rows.Add(New Object() {Textbox14.Text, Textbox15.Text})
dt.Rows.Add(New Object() {Textbox17.Text, Textbox18.Text})
dt.Rows.Add(New Object() {Textbox19.Text, Textbox20.Text})
Return dt
End Function
Regards,
Sujatha