From: Felix on
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?
From: Doug Robbins - Word MVP on
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

"Felix" <Felix(a)discussions.microsoft.com> wrote in message
news:44E8CA57-74B7-4382-84A1-26027BA751B7(a)microsoft.com...
> 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?

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

"Doug Robbins - Word MVP" wrote:

> 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
>
> "Felix" <Felix(a)discussions.microsoft.com> wrote in message
> news:44E8CA57-74B7-4382-84A1-26027BA751B7(a)microsoft.com...
> > 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?
>