Action on New Page

D

Dan Kelly

Is it possible to automatically invoke a macro when a New Page is created in
a Word Document, either by reaching the end of a page, or by inserting a page
break?

I'm thinking in a similar way to AutoNew or AutoOpen...

Word 2000 solution needed if there is one
 
J

Jay Freedman

No, you can't.

The root of the problem is that Word doesn't have any event that corresponds
to a new page. In turn, that's because pages aren't real objects in Word --
they're simply the result of recalculating the layout according to what the
printer driver says about letter spacing, margins, etc.

You could, I suppose, catch the inserted "hard" page breaks by writing
macros to intercept the Ctrl+Enter keystroke and the InsertBreak command.
But there isn't a blessed thing you can do about automatic page breaks that
occur when the page fills up.

What is it you're trying to do? Would a conditional field in a header or
footer do the job?

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
D

Dan Kelly

I've mentioned it elsewhere, but the suggested solutions, good that they are,
don't really fit our needs.

I have a template to generate a multipage columned report. Our users want
to be able to put the title of the current chapter / section on each page in
the bottom RH corner, opposite the company details.

The company details are in the footer, and the best solution I can see is to
have a text box / frame on every page. Because of our user level, using
StyleRefs and Section Headers to auto generate the contents in a frame / text
box is not a viable solution - I need to be able to have the content user
editable.

What I can't get to happen is have a text box / frame on every page - I was
hoping to have a macro fire on "NewPage" that created the appropriate blank
text box...
 
J

Jay Freedman

The only practical way to put something on every page is to put it in
the footer (or header, of course). As I said before, there is no
"NewPage" event to fire a macro.

I don't quite follow your comments about user level and having the
content user editable. Do you mean that the level of user
sophistication is low, or that it's high? If it's low, you don't want
them editing these special bits at all -- you need it to be automatic
and _not_ editable. Only the section title in its standard position
should be editable. That's exactly the situation the StyleRef field
was created for.

If you insist on reinventing the wheel and making it square :) then
you can intercept the SaveAs and Print events
(http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm) and
set up the boxes/frames (or just footer text) on all the pages at
once, before carrying out the action the user thinks s/he asked for.
Don't forget to remove any existing boxes first so you don't get
doubles.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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