By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

How to add multiple tables to MS word document using vb.net?

P: 40
i want to know how multiple tables are added to the MS word document using vb.net

i wrote following code to insert one table in MS word document using vb.net
1.opened MS word document
2.inserted one 3x3 table

Dim App As New Word.Application()
Dim Doc As Word.Document = App.Documents.Add()
Dim oTable1 As Word.Table
Dim Range As Word.Range

Range = Doc.Paragraphs.Add().Range
otable1 = Range.Tables.Add(Range:=App.Selection.Range,
NumColumns:=3, NumRows:=3)
With oTable1
.Cell(1, 1).Range.Text = "Code"
.Cell(1, 2).Range.Text = "Description"
.Cell(1, 3).Range.Text = "Units"
.Cell(2, 1).Range.Text = "1"
.Cell(2, 2).Range.Text = "2"
.Cell(2, 3).Range.Text = "3"
.Cell(3, 1).Range.Text = "4"
.Cell(3, 2).Range.Text = "5"
.Cell(3, 3).Range.Text = "6"
End With

MsgBox("saved1")
Doc.SaveAs("f:\qwerty1.doc")
Doc.Close()

i am able to insert one table,but when i am trying to insert multiple tables,
the tables are getting inserted wrongly like,one table is inserted into another table

i want code for inserting multiple tables in MS Word document using vb.net
Nov 21 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.