Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create Table within a Table.Cell

1 view
Skip to first unread message

AndyBrew

unread,
Nov 11, 2009, 2:32:05 PM11/11/09
to

Hi

Could somebody provide me with a code sample to show how to create a table
within a table cell?

Thanks in advance

Andy

Lene Fredborg

unread,
Nov 11, 2009, 4:42:02 PM11/11/09
to
The code below will create a table as a nested table inside the first table
cell of the selection:

Sub CreateTableInTable()
Dim oTable As Table
Set oTable = Selection.Cells(1).Tables.Add _
(Range:=Selection.Cells(1).Range, numrows:=3, numcolumns:=5)
'Now you can manipulate oTable, e.g. insert text
oTable.Cell(1, 1).Range.Text = "My text"
Set oTable = Nothing
End Sub

Depending on how your code is going to be used, you may need to include
error handling. For example, you may need to check whether the selection
start is in a table.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

0 new messages