Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

find text in table and insert page break

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tbaam - 05 May 2006 11:41 GMT
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.
Helmut Weber - 05 May 2006 12:25 GMT
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

tbaam - 05 May 2006 13:39 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.