Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select range after a table in word

Status
Not open for further replies.

MatDavies

Programmer
Feb 22, 2001
243
GB
I am trying to automate word so that i can dynamically insert tables. However, once i have filled the first table, the second table is inserted in to the first!
How do i select the range after the table so that it will carry on inserting in the main document?

Thanks in advance.

Matt
 
should be a better way but from the top of my head...

Code:
Option Explicit

Dim moWord As Word.Application
Dim moDoc As Word.Document

Private Sub Command1_Click()
  Set moWord = New Word.Application
  Set moDoc = moWord.Documents.Add
  With moDoc
    .Tables.Add .Range.Characters.Last, 5, 5
    .Range.Characters.Last.InsertAfter vbCr
    .Tables.Add .Range.Characters.Last, 4, 4
    .Range.Characters.Last.InsertAfter vbCr
    .Tables.Add .Range.Characters.Last, 3, 3
  End With
  
  moWord.Visible = True
  MsgBox "pause"
  
  moDoc.Close wdDoNotSaveChanges
  Set moDoc = Nothing
  
  moWord.Quit
  Set moWord = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top