Delete an entire page based on the presence of a text string

F

Felix

I need to delete an entire page based on the presence of a text string. I
tried using the code i found in the following post:

Deleting a page based on text search 6/18/2007 11:52 AM PST by Damo

'_______________________________________
Dim strSearch As String
Dim rgeStart As Range

Set rgeStart = Selection.Range

strSearch = "Subject Teacher :" & Chr(13)

With ActiveDocument.Range.Find
.Text = strSearch
Do While .Execute
With .Parent
.Select
With Selection
.Bookmarks("\Page").Range.Delete
.Characters(1).Delete
End With
End With
Loop
End With

rgeStart.Select

Application.Browser.Target = wdBrowsePage
'_______________________________________

I get a compile error on .bookmarks

Any ideas?
 
D

Doug Robbins - Word MVP

I copied that code and pasted it into the VBE and created a document with
the search string in it and it ran fine here.

--
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, originally posted via msnews.microsoft.com
 
F

Felix

Works now. Must've been a paste error... :-|

Doug Robbins - Word MVP said:
I copied that code and pasted it into the VBE and created a document with
the search string in it and it ran fine here.

--
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, originally posted via msnews.microsoft.com
 

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