move text between tables

T

Tony Logan

I'm trying to move a line of text (which will always be just a few characters
in length) from between 2 tables to the line following the second table. So
my original data structure looks like this:

table 1
line of text
table 2

What I'm trying to achieve is this:
table 1
table 2
line of text

I'm using this code to test whether the text appears between tables:
If .Previous.Range.Information(wdWithInTable) And _
.Next.Range.Information(wdWithInTable) Then

But that's where I get stumped. Any of the Move commands seem to limit me to
Line, Paragraph, Window, and Screen. Is there another command I could use to
move the text?
 
T

Tony Logan

Answered my own question. The following code, while possibly clunky, does
what I want, with the added bonus of joining the two tables that had been
separated by the text:

With Selection.Paragraphs(1)
If .Previous.Range.Information(wdWithInTable) And _
.Next.Range.Information(wdWithInTable) Then
Selection.Cut ' rejoins tables
Do While Selection.Range.Information(wdWithInTable) = True
Selection.MoveRight unit:=wdCell
Exit Do
Loop
Selection.MoveDown unit:=wdLine
Selection.Paste
End If
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top