Remove Blank pages

P

Phil Stanton

Is there any way of programmatically detecting and removing blank pages from
a document (It is possible that they may have a bookmark on the page)
Thanks

Phil
 
P

Peter

Phil Stanton said:
Is there any way of programmatically detecting and removing blank pages from
a document (It is possible that they may have a bookmark on the page)
Thanks

Phil

This should do the trick:

Sub RemoveEmptyLines()
Dim i As Long

' remove manual line breaks first
Call ActiveDocument.Range.Find.Execute(FindText:=Chr(11), ReplaceWith:="", Replace:=wdReplaceAll)

' iterate through the paragraphs, deleting those that are empty
For i = ActiveDocument.Paragraphs.Count To 1 Step -1
If ActiveDocument.Paragraphs(i).Range.Characters.Count = 1 Then ..Delete
Next i

End Sub

Might need a little tweaking, but it's the basic operation.

hth,

-Peter
 
P

Peter

Jezebel said:
That code deletes paragraphs, not pages.

hah! I would be able to help better if I would actually read the question. I though he was asking for help removing blank _lines_. :p

Blank pages, huh? Hmmm......
That'll bear some investigation. I'm thinking of iterating through the document's sections, testing for words....

-Peter
 
P

Phil Stanton

Thanks for input ....so far

I am using Office 2000 and creating the pages through Access. You are right.
The so called blank pages have either a bookmark, pagebreak or paragraph
mark. So I suppose the question should say relatively blank

Thanks

Phil
 
P

Phil Stanton

Actually you are right. If I create 5 pages, pages 1 - 4 have a bookmark and
a page break. Page 5 has a bookmark and a paragraph mark. Does this get me
closer to finding the "blank pages"

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top