word page count

W

William

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

--
 
J

Jay Freedman

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. ;-)
 
W

William

thank you, Jay.
--



Jay Freedman said:
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. ;-)
 

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