#1   Report Post  
Posted to microsoft.public.word.docmanagement
Keith G Hicks Keith G Hicks is offline
external usenet poster
 
Posts: 35
Default append row to table?

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


  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default append row to table?

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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Keith G Hicks wrote:
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



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do you append one table to another in Word 2003 Robert Perry Tables 8 September 24th 09 01:35 PM
Can you append a document in Word? dleague Microsoft Word Help 2 August 21st 07 06:56 PM
Append two documents to one, how Stan Brown New Users 18 August 28th 05 08:48 PM
Macro to Append Word Documents Cheryl B. Page Layout 2 May 6th 05 10:06 PM
how can I append one table onto another bikerick Microsoft Word Help 7 January 19th 05 05:57 AM


All times are GMT +1. The time now is 03:59 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"