#1
|
|||
|
|||
adding rows to word table
Hello
I am writing an excel macro which has to do the following: Complete a word documents based on a dot, which has different tables. The values are coming from an excel table, the target table will have at least one row, but maybe more. The first row of the table can be completed with bookmarks or docvariables, but I have to solve, that in case the mastersheet has more rows concerning the given document, then these will be also in the word in new rows in the same table. I do not have to copy the entire row from the excel sheet, but a few cells only. Does anybody know, how to do this? |
#2
|
||||
|
||||
Hi hklein,
Assuming you have your code for starting Word & creating the document in place, you could use code like: Code:
Dim i As Long, j As Long, k As Long With Doc.Tables(i) For j = 1 To k .Rows.Add Next End With
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thank you
Is there any way to mark an existing table with a name? How to refer to the cells of the newly added rows? (Or shall I open a new thread?) Thanks |
#4
|
||||
|
||||
Hi hklein,
AFAIK, tables don't have a name property. However, you can bookmark a table or you could use either the 'Title' or 'Descr' property (both of which relate to the table's 'alternative text' attribute for web pages) to identify the table. As for referencing a particular cell, taking the previous code a step further, you could use something like: .Tables(k).Cell(RowNum, ColNum).Range.Text = "My Text" where RowNum and ColNum are the row and column numbers, respectively.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Great, thank you !
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Odd behaviour of table - keep rows together | Stephan Lindner | Word Tables | 1 | 09-10-2011 05:31 AM |
Fixing number or rows in a table | burnsie | Word | 2 | 07-12-2011 02:59 AM |
Repeating table rows in template? | TheWedgie | Word | 0 | 09-11-2010 09:35 PM |
Help Autoformating a Table w 2 header rows | Julie713 | Word Tables | 0 | 03-01-2010 08:15 AM |
Table rows moving to new page when you don't want them to | graham | Word Tables | 1 | 11-16-2009 08:51 AM |