From: Felix on 9 Apr 2010 19:01 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 9 Apr 2010 20:34 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 12 Apr 2010 12:09 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? >
|
Pages: 1 Prev: Stop removing blank lines at the end of a document Next: Enable/Disable Diacritics |