PDA

View Full Version : New Page Event?



DeepBlue
06-25-2008, 04:59 AM
Hi,

I'm looking a macro for Word, something like "New Page Event", which will trigger a macro every time a new page inserted. Any suggestion?

Thanks

mikerickson
06-25-2008, 05:53 AM
You would need to intialize the named constant PageCount for this method to work.
in ThisWorkbook code module:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If [PageCount] < ThisWorkbook.Sheets.Count Then
MsgBox ActiveSheet.Name & " is a brand new sheet"
ActiveWorkbook.Names.Add Name:="PageCount", RefersToR1C1:="=" & ThisWorkbook.Sheets.Count
End If
End Sub

DeepBlue
06-25-2008, 06:03 AM
Thanks for reply, but it looks like an Excel Macro?
I'm looking for Word.

mikerickson
06-25-2008, 06:07 AM
Darn wrong forum.
I'm sorry, I don't have an answer for you, but...
Isn't the number of pages in Word dependent on the margins?
Are Pages objects that can be collected and counted?

Just babbling to cover my embarasement.

fumei
06-25-2008, 10:31 AM
No, there is no Page object, or at least not really.

No, the number of pages is not dependent on margins, although margins most certainly do effect the number of pages.

Pages are determined by Word's interpretation of the printer driver. This is crucial to understanding Word.

The very same document on a different computer,with a different printer driver, can have different pages. Heck, you can have the same document on different computers going to the SAME (network) printer, have different pages if the version of the printer driver is different.

There is no New Page Event.

It depends on what you mean by "a new page inserted". Do you mean text inserted that causes the document to spill into a new page automatically? Do you mean a manually inserted page?

In any case, there is no new page event, and there is no way to have a macro fire automatically when a new page is created. You would have to query, to check, the number of pages.