 |
Search
IT Courses |
|
|
|
|
|
|
|
|
|
|
|
IT
dart News Letter
|
Get
ITdart.com weekly headlines before it's published on our site! Subscribe
and receive the articles delivered to your inbox!
|
|
|
Managing Tables
Word tables are extremely powerful. When you want a fill-in-the blank form with a structured table, you can create tables on the fly and stuff values in these. You can then auto-format the table.
Here is the code to do so. This time we'll use Visual Basic code.
You must set reference to the Microsoft Word object library in the Project References dialog before this code can work.
Dim wrd as new word.application Dim doc as word.document Dim tbl as word.table Set doc = wrd.documents.add * Make Word visible because this is a demo wrd.visible = true * Create a new table with 3 rows and 4 columns set tbl = doc.tables.add(selection.range,3,4) * The table requires some headings * Headings are displayed in the first row Tbl.cell(1,1).range.text = "Name" Tbl.cell(1,2).range.text = "Age" Tbl.cell(1,3).range.text = "Sex" Tbl.cell(1,4).range.text = "Address" * Stuff remaining values from some data source * Now format the table using the autoformat feature tbl.autoformat wdTableFormat.wdTableFormatGrid2 Here is what the table will look like:
Name Age Sex Address Row Header Value Value Value Row Header Value Value Value
|
|
|