Dim WdTemplate As String = "C:\SW_45_Letter.dotx"
Dim WdWordTable As String = "C:\WordTable.docx"
Dim wdEmployerLetter As String = "C:\EmpLetter.docx"
Dim wdApp As New Word.Application()
Dim wdDoc As Word.Document
wdDoc = wdApp.Documents.Add
Dim wdTable As Word.Table = wdDoc.Tables.Add(wdApp.ActiveDocument.Range(0, 0), 1, 8)
wdTable.Rows(1).Cells(1).Range.Text = "EmployerName"
wdTable.Rows(1).Cells(2).Range.Text = "EmployerAddressLine1"
wdTable.Rows(1).Cells(3).Range.Text = "EmployerAddressLine2"
wdTable.Rows(1).Cells(4).Range.Text = "EmployerAddressLine3"
wdTable.Rows(1).Cells(5).Range.Text = "EmployerCity"
wdTable.Rows(1).Cells(6).Range.Text = "EmployerStatePostalCode"
wdTable.Rows(1).Cells(7).Range.Text = "EmployerZipCode"
wdTable.Rows(1).Cells(8).Range.Text = "SharedWorkPlanEndDate"
For Each wdRow As DataRow In wdDS.Rows
Dim wRow As Word.Row = wdTable.Rows.Add
wRow.Cells(1).Range.Text = wdRow.Item("EmployerName")
wRow.Cells(2).Range.Text = wdRow.Item("EmployerAddressLine1")
wRow.Cells(3).Range.Text = wdRow.Item("EmployerAddressLine2")
wRow.Cells(4).Range.Text = wdRow.Item("EmployerAddressLine3")
wRow.Cells(5).Range.Text = wdRow.Item("EmployerCity")
wRow.Cells(6).Range.Text = wdRow.Item("EmployerStatePostalCode")
wRow.Cells(7).Range.Text = wdRow.Item("EmployerZipCode")
wRow.Cells(8).Range.Text = wdRow.Item("SharedWorkPlanEndDate")
Next
wdDoc.SaveAs(WdWordTable)
wdDoc.Close()
Dim wdMailMergeDoc As Word.Document = wdApp.Documents.Open(WdTemplate)
wdMailMergeDoc.MailMerge.OpenDataSource(Name:=WdWordTable)
wdMailMergeDoc.MailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
wdMailMergeDoc.MailMerge.Execute()
wdMailMergeDoc.SaveAs(wdEmployerLetter)
wdDoc = Nothing
wdMailMergeDoc.PrintOut(True, True)
wdMailMergeDoc.Close()
wdApp.Quit()
wdApp = Nothing
ASKER
ASKER
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY
ASKER