View Single Post
  #1   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

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