Delete Pages Using VBA in Word

R

rxs0569

He
I generate a long report. The first page is reserved for a template.

So for the next round I generate a report I would like to delete all
pages except the page on which the template table exists. How can I do
this.

Maybe a simple version to delete pages 2 to end of document

thanks
Raj
 
J

Jonathan Sachs

So for the next round I generate a report I would like to delete all
pages except the page on which the template table exists. How can I do
this.

Word does not make this easy, for good reason. What's a page, anyway?
You could change all your document's page breaks by selecting a
different printer without even touching the document itself.

You can get the number of the page on which a range ends with the
expression

range.Information (wdActiveEndPageNumber)

To find the precise point where a page ends you must iterate or
perform a binary search.

If I were in your position, I would conclude that Word was telling me
not to do what I was trying to do. Perhaps it would be better to
delete everything except the first table in your document, or the
first section. Perhaps it would be wise to modify the structure of the
document, if necessary, so that one of those approaches will do what
you want.

My email address is LLM041103 at earthlink dot net.
 

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