William said:
hi,
g'd morning. does anyone has any idea how to get the page count of a
word doc. in vba for office 2003? given an obj to the doc.
thanks,
will
Hi Will,
Either of these methods will work in 2003:
Dim nPages As Variant
Dim oDoc As Document
Set oDoc = ActiveDocument ' for example
nPages = oDoc.Range.Information(wdActiveEndPageNumber)
MsgBox nPages
ActiveWindow.View = wdPrintView
nPages = oDoc.ActiveWindow.Panes(1).Pages.Count
MsgBox nPages
The Pages collection is new (I'm not sure whether it was in 2002). I haven't
yet figured out why it belongs to a Pane object, or what kinds of trouble
you can get into if you choose the wrong pane when there are more than one.
I don't think I'd use it in production code. ;-)