Problem joining tables

W

Walter Briscoe

I have two tables separated by text. I want to join the tables by
deleting the text. This is a technique I have used before with
INCLUDETEXT to form a single table. A narrow blank strip remains between
the two tables.

e.g.
I have
t1r1
t1r2
....
t1rn
text between
t2r1
t2r2
....

When I delete "text between", I get a small horizontal strip between the
two tables.

If I add rows so I have
....
t1rn
t1rn+1
text between
t2r0
t2r1
....

and select t1rn+1 to t2r0 inclusive, I can achieve the desired result by
deletion.

However, I find automating that hard. ;(

The desired result is

....
t1rn
t1rn+1
tern+2
....
 
D

Doug Robbins - Word MVP

Where does the INCLUDETEXT come into the picture?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
W

Walter Briscoe

In message <[email protected]> of Wed, 22 Oct 2008
08:34:13 in microsoft.public.word.tables, Doug Robbins - Word MVP
Where does the INCLUDETEXT come into the picture?

I must apologise, In my original posting, I forgot to say I am using
Word 2003 (11.5604.5606).

I have a main document which consists of tables separated by INCLUDETEXT
directives.

File foo.doc contains:
t1r1
t1r2
aaa{INCLUDETEXT bar.doc bookmark}aaa
t3r6
t3r7
....

"bookmark" in bar.doc consists of
t2r3
t2r3
t2r5


After the INCLUDETEXT is resolved in a mailmerge operation, I get a
document containing
t1r1
t1r2
aaa
t2r3
t2r4
t2r5
aaa
t3r6
t3r7
....

I have a macro which zaps the "aaa" lines. I want to end up with a
single 7 row table:
t1r1
t1r2
t1r3
t1r4
t1r5
t1r6
t1r7

I actually end up with 3 tables separated by by very thin blank rows:
t1r1
t1r2
t2r3
t2r4
t2r5
t3r6
t3r7

The zapping code is
' Delete aaa lines
Selection.Find.ClearFormatting
With Selection.Find
.Text = "aaa"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Loop

(That code is probably over-specified, but worked as I want in a
previous project.)
 
D

Doug Robbins - Word MVP

Try using:

Dim arange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="FD", MatchWildcards:=False,
MatchCase:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set arange = Selection.Paragraphs(1).Range
arange.Delete
Loop
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
W

Walter Briscoe

In message <[email protected]> of Fri, 24 Oct 2008
05:34:55 in microsoft.public.word.tables, Doug Robbins - Word MVP
Try using:

Dim arange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="FD", MatchWildcards:=False,
MatchCase:=True, _
Wrap:=wdFindStop, Forward:=True) = True
Set arange = Selection.Paragraphs(1).Range
arange.Delete
Loop
End With

That is wonderful! Much more elegant than my efforts.

I still do not understand what is going on. In some circumstances
deleting the paragraph from
table1
paragraph
table2

results in
table3
where table1 has table2 welded to it to form table3.
In others it results in
table1
table2
where table1 is followed by table2 without any weld.

What are the criteria for Word welding the two tables?

(I test that rows are in the same table by doing table
properties/row/next row in the last row of table1.
If the two tables weld, next row crosses to the first row of table2; if
they merely follow, next row goes to the first row of table1.)

I can probably live with separate adjacent tables rather than welded
tables. However, I am frustrated at my lack of understanding.
 
D

Doug Robbins - Word MVP

Check the Text Wrapping of the tables under the Tables>Properties dialog

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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