473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

create table in microsoft word

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
3 2111
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
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
Killer42
8,435 Expert 8TB
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

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

Similar topics

8
by: Peter Bungart | last post by:
I have a text field in Access (XP) that lists the occurrences of various plants, which are delimited within the field by commas (e.g., cactus, mesquite, yucca, cliffrose). Is there a way to...
41
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there...
0
by: Sharon | last post by:
Following up, I've found success at last with Aspose, combining both Aspose.Word to create an xml file, and then and Aspose.Pdf to create the pdf file. This works out to be quite a considerable...
6
by: dale zhang | last post by:
Hi, I am using StreamWriter to write text files now. What is the easiest way to write a word table to a file? XML + style? Thanks. -Dale
2
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
9
by: Bob Achgill | last post by:
I would like to use the timestamp on files to manage the currency of support files for my VB windows application. In this case I would only put the timestamp of the file in the management database...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
13
by: Ulv | last post by:
I have a table (TblItems) with fields Lenght, Width and Height as decimalfields. I also have the fields Desc, a text field. In a form I have created this line of code after updating: Desc =...
1
by: =?ISO-8859-1?Q?S=F8ren?= | last post by:
Hi guys I got the following code: ------------------------------------------------------- Dim Word As New Microsoft.Office.Interop.Word.Application Dim Document As...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.