Re: Inserting multiple tables into a document
- From: "Jezebel" <warcrimes@xxxxxxxxxxxxxx>
- Date: Thu, 12 May 2005 02:32:43 +0930
The trick is to insert a paragraph after each table.
Dim pTable As Word.Table
Dim pIndex As Long
Dim pRange As Word.Range
For pIndex = 1 To 5
Set pRange = ActiveDocument.Range(ActiveDocument.Content.End - 1,
ActiveDocument.Content.End)
Set pTable = ActiveDocument.Tables.Add(Range:=pRange, NumRows:=2,
NumColumns:=4)
ActiveDocument.Content.InsertParagraphAfter
Next
"Peter" <Peter@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1541922B-F519-4A1A-8BDB-A1CC81B7B127@xxxxxxxxxxxxxxxx
>I am developing a VBA program to process a number of tables in a word
> document by sorting each table then transferring the contents of each
> sorted
> table to a new table (with changed layout) in another document.
>
> My code successfully sorts the tables in the source document, and adds the
> first new table in the new document Ok, but all subsequent new tables
> appear
> to be added as nested within the first table of the new document because
> my
> insertion point appears to remain with the range of the first table.
>
> How do I programmatically change the Range Selection/Insertion point each
> time to go to a new point outside the end of the last table inserted so
> that
> when I do a Tables.Add statement it inserts the next table as a completely
> new table following the previous one? I have tried adding code:
> Selection.MoveDown Unit:=wdLine, Count =1 , but this appears to just
> extend the existing range of the current table.
>
> --
> Peter WA
.
- Follow-Ups:
- Re: Inserting multiple tables into a document
- From: Peter
- Re: Inserting multiple tables into a document
- References:
- Inserting multiple tables into a document
- From: Peter
- Inserting multiple tables into a document
- Prev by Date: DAO Error
- Next by Date: Re: Automating steps to copy URL from IE into Word
- Previous by thread: Inserting multiple tables into a document
- Next by thread: Re: Inserting multiple tables into a document
- Index(es):
Relevant Pages
|