MS Word - Search for Value and delete that page (1 Viewer)

whhaatt

Registered User.
Local time
Yesterday, 18:47
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
 

DCrake

Remembered
Local time
Today, 02:47
Joined
Jun 8, 2005
Messages
8,632
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:
 

whhaatt

Registered User.
Local time
Yesterday, 18:47
Joined
Aug 10, 2005
Messages
42
its a work generated pdf that i have converted to doc

help please - anyone
 

darbid

Registered User.
Local time
Today, 03:47
Joined
Jun 26, 2008
Messages
1,428
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.
 

oumahexi

Free Range Witch
Local time
Today, 02:47
Joined
Aug 10, 2006
Messages
1,998
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

Top Bottom