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

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?
0
Utf
4/9/2010 11:01:01 PM
word.vba.general 1023 articles. 1 followers. Follow

2 Replies
994 Views

Similar Articles

[PageSpeed] 27

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

0
Doug
4/10/2010 12:34:48 AM
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@discussions.microsoft.com> wrote in message 
> news:44E8CA57-74B7-4382-84A1-26027BA751B7@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? 
> 
0
Utf
4/12/2010 4:09:01 PM
Reply:

Similar Artilces:

How to Recover Deleted Sent Mail?
While trying to delete very old "Sent" mail I seem to have deleted all "Sent" mail. Is there a way of recovering this mail? Have you closed Outlook since deleting the old sent mail? http://www.howto-outlook.com/howto/restoredeleteditemsfromanoutlookpst.htm might help. Next time, archive the items you want removed from your active .pst file. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited mail sent to my personal account will be deleted without reading. After furious head scratching, Sidney Friedman as...

Strange negative indent in plain text messages
Recently my Outlook 2007 installation decided to indent the first line of any plain text message about half an inch to the left, resulting in the first 2 letters not being displayed as they happen to be outside the display area. That applies to editing mails as well as displaying mails in a separate window and in reading pane. Up to now I wasn't able to figure out how to reset that indent configuration. Any ideas? Thanks in advance for your help. sounds like a style is messed up. if the 'outdent' can't be changed using the Decrease indent button (next to the alignment b...

Cannot delete subreport
I am using Access 2003 and have a report I did a while back with a simple subreport. I want to remove the subreport but for the life of me can't figure out how to do it. Any help would be greatly appreciated. Thanks. Hi - When you say "remove the sub report", what do you mean? Do you want to delete the entire subreport control containing the subreport, or do you want to keep the control, but change the report contained in it? The first is easy - select the control by clicking once on it once, then press delete. For the second, click the control once, then set ...

Rule for Deleted Items
I am being told that there is a rule in place on my Exchange server that will not empty the deleted items folder every 30 days for certain users in my organization. I found a recipient policy in System Manager that says "Users Excluded from Mailbox Cleanup" but it only shows 2 users and not the 3 I was told about. But I have confirmed that the missing person has email in her deleted items folder going back to 2005 so it must be working. Is there any other location I should be looking? Also, we just had someone come in and migrate our Exchange environment from 2000 to a new...

cannot delete message from deleted items
I have a message in my deleted items folder that when choosing delete opens the McAfee box warning of potential virus and wants me to choose open or do not open, but will not delete. I have tried choosing another file and holding ctrl and choosing the file I want deleted and then choosing delete, I have tried moving it to the desktop but it will only copy there, I have tried every form of delete possible. I need help. Anyone know how? Outlook 2002. Can you empty the deleted items folder entirely? Or turn off the McAfee scanning temporarily to see if it makes a difference? Julie wr...

I can not delete a duplicate personal folders list #2
Vall... amazing that there isn't an easy fix for this. The instructions provided simply don't work ( tools-email accounts-view change email accounts-deliver to new account-finish-close outlook and reopen ), and none of the other offered explanations have worked either. As this is such a common problem; why hasn't microsoft provided a very EASY fix? I am more confused ( and frightened ) and don't want to make the problem worse! Your profile is corrupt, probably based on an incorrect migration of your ..pst file. Create a new mail profile and configure it to use your exi...

GP 10 Keyboard Page Up/Down and Mouse Wheel
After upgrading from GP 9 tp GP 10 the keyboard Page Up/Down buttons and the mouse wheel do not work when trying to advance a page of a report that was printed to the Screen as the desination. Anyone else experience this problem? If so, is there a work around? Thank you, Don It is a known issue. Click the box for the magnification. You don't even have to change the magnification. Once you click on the magnification box (or field), click in the report and you can scroll up and down. -- Charles Allen, MVP "Don Leugers" wrote: > After upgrading from GP 9 tp GP 10...

Retrieval of Deleted Items After Being Deleted from the Deleted Items File
I deleted a number of important emails from the deleted items file in Outlook 2000. This may sound stupid, but I completely emptied the deleted items file instead of deleting them one by one. Pretty stupid, huh. Anyone. Can they be retrieved? Please help. Thanks. Sorry for sending this again but I seem to be computer illiterate and it has taken me some time to explain the whole situation. Thanks again. unless you use Exchange server with deleted retention enabled, you are most likely out of luck, but you can try something that might help.... http://www.outlook-tips.net/howto/r...

Horizontal Page Breaks
HI: Can anyone tell me if there is a limit to the number of horizontal page breaks I can have in a work sheet. I have a sheet with 43 Pages, which ends at Row 2066. When I add another page, I am unable to pull the print area down any further. If I go up a few rows and insert a page break, I can adjust that just fine. However, I can still not pull it past row 2066. Thanks, Sam I ran this macro: Option Explicit Sub testme01() Dim iCtr As Long ActiveSheet.ResetAllPageBreaks For iCtr = 2 To 65536 Step 2 ActiveSheet.HPageBreaks.Add before:=Cells(iCtr, "A") ...

Adding text content to Memo field
I have two memo fields, Memo1 and Memo2. Memo1 cannot be edited (its locked property is set to true). So I have the user enter text notes in Memo2, and then I have a command button that allows the user to add the contents of Memo2 to Memo1with the current date. My code is as follows: Me!Memo1 = vbCrLf & Format(Date, "mm/dd/yyyy") & vbCrLf & Me!Memo2 & vbCrLf & Me!Memo1 Now I am recieving an error message: "Could not update. Currently locked by another session on this machine". I belive I have about 72K characters in the Memo1 field and was wondering if ...

Delete macros
I am using Excel 2002. When I click on Tools->Macro->Macros... i see 2 macros. The problem I am having is that I can't delete these macros, the delete button to the right is grayed out. How can I delete these macros? Hi maybe the macros are protected. Try hitting ALT + F11 to open the VBA editor and try to delete the macros / modules there -- Regards Frank Kabel Frankfurt, Germany excel777 wrote: > I am using Excel 2002. When I click on Tools->Macro->Macros... i see > 2 macros. The problem I am having is that I can't delete these > macros, the delete button to ...

Prints blank page first?
I created a publication on one computer (Pub 2000, Win98SE), burned it to a CD, and am trying to print from another computer (Publisher 2000 with Win2000 and an HP Deskjet printer). Ctrl+P, Print page 1 to 1 - and I get a blank sheet coming out first, then Page 1. Same thing happened with Page 2. Did I miss a setting somewhere? Ed Did you try copying the file to the hard drive first and then print? Open the printers and fax folder in the control panel, right-click your printer, properties, advanced tab, separator page button, clear anything it may say in the "separator page"...

Check boxes to text 05-12-10
Is there any way that I can have check boxes automaticaly transfer their information to text? example: Check boxes = red, blue, green If you click the red and green check boxes, the title would be as bellow. Title on the page = Lable order for: red, green Thank you Again, what you ask is at present incomprehensible. If the link I posted earlier does not work for you then the alternative is a userform - For the basics, see Word MVP FAQ - Userforms http://word.mvps.org/FAQs/Userforms.htm for a more in depth explanation, see http://gregmaxey.mvps.org/Create_and_employ_a_User...

pie chart legend text
My pie chart has 10 data values (e.g. 10 sectors). The legend shows a little box with the color that coordinates with each sector and they are automatically numbered 1 thru 10. I have the data in a column and the respective text in an adjacent column. I want the legend text to come from the spreadsheet. Right now, I get numbers 1 thru 10 next to the little box and I cannot seem to change the text. Maybe I have the data set up wrong? Should it be something other than columns? Tnx in advance for any help Brian becoon@twcny.rr.com Brian - A little work up front saves trouble lat...

page edition problems
I have created a page in PowerPoint, with an image, colored fonts, filled rectangles, and I am trying to send it as an email (not as an attached file) in Outlook. Cut and Paste gives a deteriorated result. I have tryied exporting the page out of PowerPoint in different formats, but I never get a result which gives a clear, professional looking email page. I have even rebuilt the page in Outlook: when I send it out it is ok, but at the receiver's side all the blocks of the page move to adjust to their window size and resolution. I am desperate to find a working solution. Thank you very much...

deleting email in outlook, freezes before i can delete
i have a file with pics that symetec scanner says is to large. i can receieve email but cannot send any. it freezes before i can delete and says non responding. Hi All, I want to re-raise the old issue of Fax numbers showing up in the Outlook Address book when one is sending an email. I know that this can be stopped by prepending the Contact's fax number with a letter so that Outlook doesn't see it as a valid fax number and therefore doesn't list it. What's always puzzled me, however, is that this fix doesn't work if the fax numbers are changed using an export to CSV...

OK to delete Deleted Items folder?
I'm afraid I'll have to delete my Deleted Items folder in Outlook 2000. When I try to empty the folder I get a "The messaging interfce has returned an unknown error. If the problem persists Restart Outlook" message. Is it possible to delete the entire folder and replace it with an empty new one? Will it create any problems? TIA Henrik Not possible. Run scanpst.exe against your pst-file to scan it for errors first. -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -What do the Outlook Icons Mean? -Create an Office 2003 CD slipstreamed with Se...

Combining pages
How do I combine two A4 pages of pictues in to a single publisher document? Alan wrote: > How do I combine two A4 pages of pictues in to a single publisher > document? ================================ Add a blank page to the target document. To add the second page...Select All / Copy / Paste. FWIW...you can open more than one instance of Publisher. -- J. Inzer MS-MVP Digital Media Experience Notice This is not tech support I am a volunteer Solutions that work for me may not work for you Proceed at your own risk ...

How do I set up an incoming hyperlink to a page within a frame?
I have a web site that uses frames under FrontPage 2003. Each frame typically contains a banner page, a contents page and a main page. How does another web site hyperlink to a bookmark within a paricular main page so that the banner and contents pages are displayed as well (ie. together with the main page). Without these, it is impossible to navigate around the web site after the hyperlink is executed. No Link to your Website ....... No Help for Website we do not know if It is a <frameset></frameset> Or <iframe></iframe> Add-to-favorites Script for if...

Update field w/ string based on due dates
Hi, I have a form that provides a listing of various instruments that are serviced on a monthly to annual basis, with general info about the instrument, last and next service dates, etc.. What I am trying to do is create an On Open event procedure that will identify all instruments that are listed with a string of either "Past Due" or "Schedule Vendor" based on whether each of their respective 'Due' dates have already transpired or not from the current month. The code I initially created for this was as follows: Private Sub Form_Open() Dim myDate, myDue myDa...

How to delete chart
I created a histogram and want to delete it. I select it and the faint double border apperars. There are no square handles like in 2003. Then I press the Delete key. The faint double border goes away replaced by a single thin black border. The chart is still there and is not able to be selected at all. I entered "delete chart" in the Excel Help window, and there was nothing at all on deleting a chart. Ditto for "remove chart." I got no help searching on the internet either. I have Excel 2007 and Windows XP Professional When the border changes, can you press Delete a...

Delete blank Last page
In a word document where the last page is blank due to editing or whatnot, how do you get rid of the frigg' thing. This is a Visio newsgroup - your question was about Word. However, I have had this problem as you have. Narrowing the margins and line spacing on the page previous to the last may get rid of this annoying "blank" page for you. - Jeff Chapman "silkies" <silkies@discussions.microsoft.com> wrote in message news:BDCC1FF1-50D0-42CE-BA84-868CB26A43AC@microsoft.com... > In a word document where the last page is blank due to editing or > whatnot...

Deleting an email
I have an email (with a file attached) that is "hung up" in my outbox of Microsoft Outlook. Now I can't send or receive emails in Outlook. How can I delete the email that is "hung up"? Define hung up. Is it trying to send it? If so, disconnect your connection while it's trying to send and wait. It will time out after a bit and you should be able to delete it. Reconnect. "Aaron Hurliman" <AaronLHurliman@aol.com> wrote in message news:03b001c34f39$0fb61ff0$a301280a@phx.gbl... > I have an email (with a file attached) that is "hung up&q...

Extracting the number from a text
Hi, In a cell say C3, the value is such as S9(09)V(05). the value of that cell might be in one of the following format: (1) S(9)V(5) (2) S9(09)V(05) (3) S9(9)V(05) (4) S9(09)V(5) (5) S(11) My requirement is: i need to get the numbers extracted which, is present before & after the letter 'V' & enclosed in parantheses. In some cases, the letter V may not be there. (for ex: point 5 - here, only one number is there ie.11) This extraction should happen ONLY if the cell E3 has the value "COMP-3." Thanks in Advance. Venkatesh V First number: =IF($E$3="COMP...

Recovering Unrecoverable Deleted Public Folders
Long, sad story with a punch line (which is worth getting to): Exchange 2003. Ran into a situation where a user deleted 10 public folders by mistake. Using Recover Deleted Items to retrieve them, got back five of the folders (the ones that were empty in the first place) but we received the following error message when attempting to recover the other five (the ones with actual stuff in them): "Outlook was unable to recover some or all of the items in this folder. Make sure you have the required permissions to recover items in this folder and try again. If the problem persists contact you...