Printing from VBA, actual page not page number

D

dtshedd

I am trying to print a range of pages, based on the sequence of the
pages from the beginning of the document and not based on user defined
page numbers.

I have 700+ documents, where the author has set page numbers starting
with Roman numerals for the cover page and TOC (ie i,ii, iii, iv) and
then starting with numeric (1,2,3,4) values for text body. I would
like to print based on the actual page, consistent with the value shown
in the status bar (i.e. "4/11" page 4 of 11, found to the right of the
section identification).

I have tried using the printout method both the From: and To:
designator or the "Pages"=" option. Both times I get page numbers not
actual pages.

Ultimately I am trying to tie the print ranges to bookmarks present in
the document. I am using the following command

intPageNo = Selection.Information(wdActiveEndPageNumber)

to get the page number of the bookmark. This command appears to return
the actual page, not the page number assigned by the user.

I would appreciate any help.
 
D

David Sisson

Is the manual page number in the footer? If so, could you read the
last page, read the manual page number, and calculate the pages wanted?

If the manual page number is in the body, then you will have to recurse
through the sentences to look for the manual page number.
 
H

Howard Kaikow

Private Sub GetPageNumbers()
' wdActiveEndAdjustedPageNumber: Returns the number of the page that
contains the
' active end of the specified selection
or range.
' If you set a starting page number or
make other manual adjustments,
' returns the adjusted page number
(unlike wdActiveEndPageNumber).
' wdActiveEndPageNumber: Returns the number of the page that contains the
' active end of the specified selection or
range, counting from the beginning
' of the document. Any manual adjustments to
page numbering are disregarded (
' unlike wdActiveEndAdjustedPageNumber).
With Selection
MsgBox "Selection is on page " & .Information(wdActiveEndPageNumber)
& "," & vbCrLf _
& "adjusted page number is " &
..Information(wdActiveEndAdjustedPageNumber) & "," & vbCrLf _
& "number of pages in document is " &
..Information(wdNumberOfPagesInDocument) & "."
End With
End Sub
 
D

dtshedd

Thanks to those who replied. The code is evry interesting, but I think
my problem is not with retrieving the page number of the bokmark, that
appears to work fine, the problem is with the Printou method which does
not appear to recognize actual pages. As an example, if I print using
the menus and specify a page range in the dialog, I will get user
defined page numbers not actual page numbers. Does anyone know a way
around this short of removing page numbering? I prefer not to do this
as the orignial printed documents had page numbers and I am trying to
maintain semblance with the hardcopy, but in softcopy form.

Thanks again for the responses.

Dan
 

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