append row to table?

  • Thread starter Thread starter Keith G Hicks
  • Start date Start date
K

Keith G Hicks

I have a dot file that contains a table. I need to populate that table via
VBA from MS Access. I've done this sort of things many times but what I need
to do here appears to be different than what I'm used to.

There is a header row in the table. Then I have 1 detail row below that. I
presently have bookmarks in each cell of that row. The problem is that the
code I'm writing will need to add sevearl more detail rows the number of
which can vary from customer to customer.

The first question is how can I "append" a new row in code so that the new
row goes to the end instead of "inserting" it above the current row?

The second question is what is the best way to get the data into the other
rows since I can only have one set of bookmarks for the first row? Should I
abandon bookmarks altogether and just use "TAB" in code to get to where I
need to be on the form before posting the data to it?


Thank you,

Keith
 
The statement

myTable.Rows.Add

adds one new row at the end of the table (I assume you've assigned the Table
object named myTable to point to the correct table in the document). The
..Add method can take an optional parameter containing the index of an
existing row, and the new row would be added before that existing row. Omit
the parameter completely to put the new row at the end.

Each cell of the table is independently addressable without bookmarks. As an
example, if you want to put text into the second cell of the last row of the
table, you can do something like this:

Dim lastRow As Long
...
myTable.Rows.Add
lastRow = myTable.Rows.Count
myTable.Cell(lastRow, 2).Range.Text = "some text"

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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

Back
Top