DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Insert a table within a table

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Insert a table within a table

    [Originally posted by Mar]

    Hi All,

    May I know how can I insert a table within a table?

    I have the following code snippets:
    Set myRange = Doc.Paragraphs(intPara).Range
    Set myTable = Doc.Tables.Add(myRange, 1, 1)

    The problem is that I cant find any way to add the 1x1 table into the cell that i want.

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Insert a table within a table

    [Originally posted by PhantomsHorridC]

    HI ya, try this ;}



    Sub CreateTableInTable()

    'Creates a Table 2 by 2
    Call InstertTable(2, 2)

    'Find Table 1
    Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1
    Selection.Find.ClearFormatting
    Selection.Find.Execute

    'Moves to the 2nd Cell
    Selection.MoveRight Unit:=wdCharacter, Count:=1

    'Creates a Table 3 by 2
    Call InstertTable(3, 2)
    End Sub

    Sub InstertTable(Rows As Integer, Cols As Integer)
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=Rows, NumColumns:= _
    Cols, DefaultTableBehavior:=wdWord9TableBehavior
    With Selection.Tables(1)
    If .Style <> "Table Grid" Then
    .Style = "Table Grid"
    End If
    .ApplyStyleHeadingRows = True
    .ApplyStyleLastRow = True
    .ApplyStyleFirstColumn = True
    .ApplyStyleLastColumn = True
    End With
    End Sub


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center