MS Word - Search for Value and delete that page

whhaatt

Registered User.
Local time
, 18:31
Joined
Aug 10, 2005
Messages
42
I need help

I have a 5000 page document and I need to run a macro so that it searches for a value (eg - "32 entries per line") and if that value is found then THAT page that the entry is found is deleted and so on until the end of the document.

Can someone help me with the macro/vb code required? :confused:

I have this code but I need the search coding.

Code:
Sub DeleteCurrPage()
'
' DeleteCurrPage Macro to delete the current page
'
    ActiveDocument.Bookmarks("\Page").Range.Delete
End Sub
 
Silly question but here goes. What type of word doc has 5000 pages? and how did it get that big. The bible or war and peace uses less pages.:eek:
 
its a work generated pdf that i have converted to doc

help please - anyone
 
I dont have a solution for you but I know how I would approach it.

The search - Word has a great search function. Record a macro and search for something. Then open up the Word VB editor and you will see how the VBA looks. This is going to be a good start.

The problems are where Word finds your results more than once.

Then I think that if the searched term is found it is a selection. Then we need to work backwards to get the page it is on so we can delete it.

If you get the search working and post that code I am pretty sure we can work backward with it.

edit: i would think that a 5000 page word doc is impossible. I had a couple of 100 with pictures and it was very slow.
 
I think what I would do is, firstly change all page breaks to section breaks, then I would insert line numbering for the entire document restarting the numbers at each section break.

Your macro can then search for the line number 32 in that section, when it find it, instruct it to go to the next page (or section break), then select upward to the top of the previous page (or section break) and delete.

Hope this helps.
 

Users who are viewing this thread

Back
Top Bottom