Oh, forgat to mention:
Set oTable = .Tables.Add(oRange, 3, 2)
Makes a table with 3 rows and two columns, at the start of oRange.
Grtz.©
D.
Main Topics
Browse All Topicshi,
I want to add a number of different tables to a word document from a visual basic program. The table can be of different sizes, and can have different number of columns, from 1 to 4 columns. Does anybody have code to do this, or can you point me to a website?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
thats good, i have a further addition, i want to put bullet points into the right most column/ cell of a table, is this possible? i also have a complex table that i want to create, can somebody email me at irish_male_24@yahoo.com if you want me to send you a copy of the type of table i need to create
Hi IrishProgrammer,
Yes, that is possible. In the code I assume you know how many columns you have in the table (2), otherwise you need to make the column position into a variable.
Private Sub cmdAddBulletToCell_Click()
Dim oTable As Word.Table
' ------------------------
On Error GoTo PROC_ERR
If (m_oDocument Is Nothing) Then
MsgBox "No document to put bullet in"
Else
Set oTable = m_oDocument.Tables(1)
If (oTable Is Nothing) Then
MsgBox "Can't get the table!"
Else
oTable.Rows(1).Cells(2).Ra
End If
End If
PROC_EXIT:
If (Not (oTable Is Nothing)) Then
Set oTable = Nothing
End If
PROC_ERR:
Select Case Err.Number
Case Is <> 0
MsgBox Err.Number, Err.Description, vbOKOnly + vbInformation, Err.Number
Err.Clear
Resume PROC_EXIT
End Select
End Sub
This code is an extension on the code I gave in my first comment. You can add another button, and name it "cmdAddBulletToCell". Then paste the code in, and run the program.
Grtz.©
D.
Hi irishprogrammer,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept daffyduck14mil's comment(s) as an answer.
irishprogrammer, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Business Accounts
Answer for Membership
by: daffyduck14milPosted on 2002-08-12 at 09:00:50ID: 7214627
Hi,
tAfter ("Test")
sdn
Make a new project, add a reference to the Word objects, then add three buttons, named cmdOpenWord, cmdNewDocument and cmdInsertTable and run the program.
Press the button to open word, then the button to make a new document, then the button to add the tables.
Option Explicit
Private m_oWord As Word.Application
Private m_oDocument As Word.Document
Private Sub cmdInsertTable_Click()
Dim oRange As Word.Range
Dim oTable As Word.Table
If (Not m_oDocument Is Nothing) Then
With m_oDocument
Set oRange = .GoTo(wdGoToPage, 1)
Set oTable = .Tables.Add(oRange, 3, 2)
MsgBox oTable.Rows.Count
oTable.Rows(1).Range.Inser
Set oTable = Nothing
Set oRange = Nothing
End With
End If
End Sub
Private Sub cmdNewDocument_Click()
If (m_oDocument Is Nothing) Then
Set m_oDocument = m_oWord.Documents.Add()
End If
End Sub
Private Sub cmdOpenWord_Click()
If (m_oWord Is Nothing) Then
Set m_oWord = New Word.Application
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set m_oDocument = Nothing
Set m_oWord = Nothing
End Sub
The information came from the MSDN library, you can find usefull information about the word object model there. No better source then microsoft itself. The URL is http://www.microsoft.com/m
Grtz.©
D.