By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,440 Members | 1,041 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,440 IT Pros & Developers. It's quick & easy.

create table in microsoft word

P: 88
How do I create a table with a set number of columns but indefinite number of lines in Microsoft Word, and populate each row by looping through an array?
Sep 14 '07 #1
Share this Question
Share on Google+
3 Replies


P: 88
Bump bump...

...I really need help with this. I want to enter some information into textboxes to insert it into a list in a userform, and then take every item in the list and write a table row for it in a table in Microsoft Word. I can probably figure out a way to get the data from the userform into an array, but how do I get the data from the array into the Word table?
Sep 17 '07 #2

P: 88
I found it!

I created the first row of the tables directly in Word (which didn't matter, since it only contained column headers), and then used the following code to insert data into the cells:

Expand|Select|Wrap|Line Numbers
  1.     Dim tblItems As Word.Table
  2.     Set tblItems = appWord.ActiveDocument.Tables(4)
  3.     ' my table was the fourth to appear in the word document
  4.  
  5.     tblItems.Rows.Add    ' to add a row
  6.  
  7.     tblItems.Cell(tblItems.Rows.Count, 2).Range.Text = "hello world"   ' to insert the text "hello world" into the second column of the last row
Sep 17 '07 #3

Expert 5K+
P: 8,434
I found it!
Excellent!

I'm sorry to see you didn't get any response to your question. We try to tackle everything that comes our way, but our VB "staff" are seriously overworked at the moment.

I use the word "staff" loosely, of course - this is entirely a volunteer forum. The experts are generally just people who came here to ask a question and decided to stick around and provide answers.

Thanks for posting the answer you found. This will be helpful for the next person who comes looking for the info.
Sep 18 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.