code for finding out if a page is blank and then delteing it

N

Nishanth

Hi,
Does anybody know how to check if the word page has any content in it or
not?
space characters and carriage returns should be considered as empty
characters.
After checking if the page is blank I want to delete this page.

Thanks
Nishanth
 
H

Helmut Weber

Hi Greg,

is under close observation. ;-)

If I didn't know, you like it, i'd keep my mouth shut.
There seems to be a problem with removing:
tab space space tab tab space tab space space paragraph.
You probably have to use some kind of recursion.

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
G

Greg

Helmut,

It isn't designed to clean up a leading or trailing pattern like you
described and so yes it would need to be run several times to clean up
that mess ;-)

For example if the text were:

$$$$Helmut
%%%%Helmut
$%$%$Helmut

and the characters entered were $,% the result would be:

Helmut
Helmut
$%Helmut
 
G

Greg

Helmut,

By your observation I see that Clean Up Text is not necessarily the
total solution to Nishanth's problem :-(
 
G

Greg

Nishanth,

While you can't actually delete pages from a Word document like ripping
a blank page out of a book, you can look at the text contained in the
display representation of a page and if that representation contains
only white space characters then delete them.

Try something like:

Sub Test()
ActiveDocument.Bookmarks("\Page").Select
With Selection.Find
.ClearFormatting
.MatchWildcards = True
.Wrap = wdFindStop
.Text = "[! ^13]"
.Execute
If Not .Found Then
Selection.Delete
End If
End With
End Sub
 

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