Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2011, 10:05 AM
hklein hklein is offline adding rows to word table Windows XP adding rows to word table Office 2007
Novice
adding rows to word table
 
Join Date: Jul 2011
Posts: 23
hklein is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 07-17-2011, 05:22 PM
macropod's Avatar
macropod macropod is offline adding rows to word table Windows 7 64bit adding rows to word table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
where 'Doc' is the document you're working on, 'i' is the table in the document and 'k' is the number of rows to add.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-17-2011, 11:52 PM
hklein hklein is offline adding rows to word table Windows XP adding rows to word table Office 2007
Novice
adding rows to word table
 
Join Date: Jul 2011
Posts: 23
hklein is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 07-18-2011, 12:14 AM
macropod's Avatar
macropod macropod is offline adding rows to word table Windows 7 64bit adding rows to word table Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 07-18-2011, 12:21 AM
hklein hklein is offline adding rows to word table Windows XP adding rows to word table Office 2007
Novice
adding rows to word table
 
Join Date: Jul 2011
Posts: 23
hklein is on a distinguished road
Default

Great, thank you !
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding rows to word table Odd behaviour of table - keep rows together Stephan Lindner Word Tables 1 09-10-2011 05:31 AM
adding rows to word table 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
adding rows to word table Table rows moving to new page when you don't want them to graham Word Tables 1 11-16-2009 08:51 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft