How can I create and use Tables in Microsoft word document through VB .net?
I've been using the following code for printing an envelope using
paragraphs. Tables have to be used for better formatting.
----------------------------------------------------------------------
Dim w As New Microsoft.Office.Interop.Word.Application
Dim d As Microsoft.Office.Interop.Word.Document = w.Documents.Add
w.Visible = False
d.PageSetup.PaperSize =
Microsoft.Office.Interop.Word.WdPaperSize.wdPaperE nvelope10
d.PageSetup.VerticalAlignment =
Microsoft.Office.Interop.Word.WdVerticalAlignment. wdAlignVerticalCenter
d.PageSetup.Orientation =
Microsoft.Office.Interop.Word.WdOrientation.wdOrie ntLandscape
With w.Selection
..Font.Name = "Verdana"
..Font.Size = "11"
..ParagraphFormat.Alignment =
Microsoft.Office.Interop.Word.WdParagraphAlignment .wdAlignParagraphCenter
..TypeText(String.Format("To,{0}{1}{2}{3}", vbNewLine, ComboBox1.Text,
vbNewLine, toAdd.Text))
..TypeParagraph()
..ParagraphFormat.Alignment =
Microsoft.Office.Interop.Word.WdParagraphAlignment .wdAlignParagraphRight
..TypeText(String.Format("From:{0}{1}{2}{3}", vbNewLine, TextBox2.Text,
vbNewLine, TextBox1.Text))
End With
d.PrintOut(True, True)
d.Close(Microsoft.Office.Interop.Word.WdSaveOption s.wdDoNotSaveChanges)
w.Quit()
--------------------------------------
Regards,
Nitin