View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Retrieving page number count from Word DOC

You say "doc" and Word, but you code is for an Excel worksheet. Confused ??

If it is Excel, maybe you have the PrintArea set to those 2 pages.

NickHK

"Garbunkel" wrote in message
...
Hi NickHk,

Thanks for your response. I tried the code you sent & it still outputted

a
'2' for the pagecount. The actual number of pages in the doc I worked

with
is 21.

Is this only counting the number of manual page breaks?

Please advise.
--



"NickHK" wrote:

Try the old way:
Dim PageCount as long
pagecount=ExecuteExcel4Macro("GET.DOCUMENT(50)")

NickHK

"Garbunkel" wrote in message
...
Hi all,

I am working with an Excel VB script (V6.3) to extract data from a set

of
Microsoft Word DOC files. I need to use a VB solution to retrieve the

page
number count (the actual number of pages that would be printed if I

hit
the
'Print' button) from a Microsoft Word DOC file. I tried the following

way:

Dim ActiveWB As Workbook
Set ActiveWB = ActiveWorkbook

ActiveWB.Worksheets(1).DisplayAutomaticPageBreaks =

True
HorizBreaks = ActiveWB.Worksheets(1).HPageBreaks.Count
HPages = HorizBreaks + 1
VertBreaks = ActiveWB.Worksheets(1).VPageBreaks.Count
VPages = VertBreaks + 1
NumPages = HPages * VPages
ActiveWB.Worksheets(1).DisplayAutomaticPageBreaks =

False
ActiveWB.Worksheets(1).Cells(1, 1).Value = NumPages

...but it always comes back with a '2'

Any assistance I can get on this would be greatly appreciated.

- Michael