Create multiple stacked tables in word using vb.net

J

Jenny Beavers

Hello everyone, I am glad I found you!
Here is what I am using:
Word ver 2002
OS XP
VB.Net

In vb.net I need to find a certain location in a Word template, then add
multiple tables fed from a dataset with a line in between each table
containing descriptive text. I have tried creating bookmarks on the fly and
adding a table to each bookmark without much success especially in where and
how they appear.
The tables need to be stacked so to speak on top of one another with a
descriptive line of text in between each table.
One of the main problems I have is in determining how to create the bookmark
locations to be one after the other(possibly with a space in between).
Maybe bookmarks are not the way to go.

Thanks in advance for any response.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?SmVubnkgQmVhdmVycw==?=,
Hello everyone, I am glad I found you!
Well, still not *quite* the right place (an office.developer group would be
better; this group caters to end-users), but definitely a good place to start
:)

Basically, you have to proceed like this:

1. Find the starting point (for the first table).

Note: you should be working with RANGES, not SELECTION objects.

2. Insert the first table, roughly:

Dim tbl As Word.Table = rng.Tables.Add 'Parameters here
'Populate and format the table

3. Now move the position outside the table, using a range
Dim rngTbl =tbl.Range
rngTbl.Collapse wdCollapseEnd
'This is just below the table
rngTbl.Text = "Text between the tables" & vbCR
rngTbl.Collapse wdCollapseEnd
tbl = Nothing
tbl = rngTbl.Tables.Add 'etc.
Here is what I am using:
Word ver 2002
OS XP
VB.Net

In vb.net I need to find a certain location in a Word template, then add
multiple tables fed from a dataset with a line in between each table
containing descriptive text. I have tried creating bookmarks on the fly and
adding a table to each bookmark without much success especially in where and
how they appear.
The tables need to be stacked so to speak on top of one another with a
descriptive line of text in between each table.
One of the main problems I have is in determining how to create the bookmark
locations to be one after the other(possibly with a space in between).
Maybe bookmarks are not the way to go.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
J

Jenny Beavers

Cindy,
Thank you for your response, your example is very clear and helpful. Also, I
am sorry for posting In the wrong area.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top