PDA

View Full Version : Solved: Is there an event to catch if a document goes over one page?



sandam
04-01-2005, 04:33 AM
I was just wondering if there is an event that can be trapped that tells when a document has gone over into two or more pages?

Basically I would liek to watch for the event and then format page number two to a different page setup/footer etc.

Andrew;?

Killian
04-01-2005, 04:58 AM
Back to the page numbering nightmare, eh? :(
I think this might be a problem though, because Word doesn't really "think" in terms of pages. In fact I've noticed when using fields for page numbers that until you do something that forces it to repaginate the doc (like printing) it will quite happily tell you all your 20 pages are all page 1 of 1 ?!
I've always thought a Document_Change event would be a nice addition but no such luck.
Sorry... I've been stumped on this before :dunno

K :-)

sandam
04-01-2005, 06:02 AM
ah well, it was worth a shot :)

Killian
04-01-2005, 06:09 AM
Indeed it is. Mind you, I don't know if you should mark it as solved just yet. One of the Word specialists may know of a trick. That's the thing I find with Word VBA, you have to know all these wierd unintuative tricks to do seemingly obviuos things...

sandam
04-01-2005, 08:19 AM
alright then. don't know how to unsolve a thread - probably an admin only option. And yeah - excel VBA what little I know of it is cool because its mathematical in feeling however word VBA is just plain stubborn.

------------------------------------------------------------------------------

I think I won the battle but I'm not too sure about the war. I managed to bend the sections object to my will - sort of. I found it all has to do with sections. The software that creates the document inserts a superfluous coninous section break (this really annoyed me) till i figured out that i can set section1 as well as section 2's footers at the same time, even if there is only one page. So I setup up the document with this in mind. It works and now i just have to see if the field codes stay visible or not post insertion - I think its a template thing as I'm writing this code in a special global template that the merged doc will use. We'll see.



Thanks again for the help killian

Andrew;?

EricFletcher
04-01-2005, 11:18 AM
This is a common practice for page one of a multi-page letter. Here's how I do it in my personal letter template:

1. In Page Setup, Layout tab, turn on the different first page checkbox for headers and footers.

2. Create a footer for the first page with only the following field (note that the braces need to be the ones Word puts in when you create a field with Ctrl-F9):
{ if { numpages } >1 /...2" "" }

Now if the letter fits fully on one page, the condition is false so no footer shows up. However, if it flows over to a 2nd page, the condition is true so the /...2 appears at the bottom of page 1. If you use this in a template for letters, it will be there automatically for you.

Note that if you adjust a letter to get it back to a single page, you may want to flip from Print Layout view to Normal view and back to "recalculate" the page footer.

Tip: If you use the envelope feature to add an envelope to the document, the envelope will be added as a new first section, making the letter >1 page. If you tend to use this feature, I'd suggest using the SectionPages field instead of numpages so the If condition only counts pages in the letter section.

Howard Kaikow
04-06-2005, 06:57 AM
I was just wondering if there is an event that can be trapped that tells when a document has gone over into two or more pages?

Basically I would liek to watch for the event and then format page number two to a different page setup/footer etc.

Andrew;?

you do not need an event.

just create the necessary headers/footers in advance, using different 1st page headers/footers.

sandam
04-06-2005, 07:00 AM
thats exactly what i've done :) :thumb:

Anne Troy
04-06-2005, 07:16 AM
For anybody who wants to use this link in future (wish I'd seen this thread, doh!):

www.vbaexpress.com/EE/ltrheadtmplt.doc (http://www.vbaexpress.com/EE/ltrheadtmplt.doc)

sandam
04-06-2005, 07:26 AM
Thanks dreamboat. My biggest problem is that post merge the document loses certain properties and I had to account for those. i wish it was as simple as just creating a header and footer. Dang nabbit 3rd part software! :banghead: But the issue is definitely resolved now. All thats left is making everyone think like me so they don't break the macros ;)

Anne Troy
04-06-2005, 07:29 AM
Uh oh!
Futile.
I've been trying to get my husband to think like me for years.
Futile.