Question : Silly Question - Move out of a table

Hi,

I've created some code that adds a single table to a word document.

I would now like to add another table underneath.  The problem is if I try to add another table it just sticks in the first cell of the first table - essentially nesting it.

How can I programmatically move out of 1 table, add a paragraph and then add another table?

I'm sure its easy but it confusing me?

I've read that I shouold be able to achieve something like what I need by using ranges - I tried this but it did nothing:

            myRg = Wrd.ActiveDocument.Range
            myRg.Collapse(WdCollapseDirection.wdCollapseEnd)
            myRg.Text = vbCr

Where myRg is a Range

Any help appreciated.

Answer : Silly Question - Move out of a table

You are very nearly there. Here is a VBA version
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Sub AddTable()

    Dim tbl1 As Word.Table
    Dim tbl2 As Word.Table
    Dim rng As Word.Range
    Dim doc As Word.Document
    Dim wdapp As Word.Application
    
    '...
    Set doc = wdapp.ActiveDocument
    Set rng = doc.Tables(1).Range
    rng.Collapse wdCollapseEnd
    rng.Text = vbCr
    rng.Collapse wdCollapseEnd
    Set tbl2 = doc.Tables.Add(rng, 3, 4)
    
End Sub
Random Solutions  
 
programming4us programming4us