I have a table that extends over multiple pages.
I would like to search for certain text, which is only found in the first
column.
Once this text is found I would like to insert a page break about the row
that the
text is found in. This text would be found in more then one row.
Thank You for you help.
Hi tbaam,
like this:
Sub Test8970()
Dim rTmp As Range
Set rTmp = ActiveDocument.Tables(1).Range
With rTmp.Find
.Text = "test"
.Forward = False ' !!!
While .Execute
If rTmp.Information(wdEndOfRangeColumnNumber) = 1 Then
rTmp.Collapse
rTmp.InsertBreak Type:=wdPageBreak
End If
Wend
End With
End Sub
Without modification that works on the first table in the doc only.
And, note, inserting a pagebreak, splits a table, as far as I know.
Therefore, if "test" is found 7 times,
the number of the tables increases by 7.
The trick is to do it backwards.
If forward would be true, then
after the first find the table would be split,
but no more "test" would be found in the first table.
HTH

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Helmut Weber - 05 May 2006 12:32 GMT
hmm...
it is assumed, that "test" is found
at the start of a table cell.
Otherwise, ask again,
can all be done.

Signature
Helmut Weber, MVP WordVBA
Ahh...again PERFECT!
You can't even imagine how close I was....it was the going backwards I
couldn't figure out.
Life is Good!
Thanks
> I have a table that extends over multiple pages.
> I would like to search for certain text, which is only found in the first
[quoted text clipped - 4 lines]
>
> Thank You for you help.