Way to print out more then first page

C

Cameron

I have a word document that has a Table of Contents that uses hyperlinks. The
user selects the article they would like to view via the TOC and is taken to
the document. from there they click on a button on the page that is to print
out the document currently in view. However some of the documents have
overflown into two or more pages. Is there a way to build a function that the
document runs prior to the user clicking on the TOC so that the function
knows the number of pages assigned to each link in the TOC. That function
then passes the number of pages to the Application.PrintOut method to assure
that all the pages are printed?

The function would have to be smart enough to figure out the pages as this
function would be embedded in a template file for further use by the users.
 
C

Cindy M.

Hi =?Utf-8?B?Q2FtZXJvbg==?=,
I have a word document that has a Table of Contents that uses hyperlinks. The
user selects the article they would like to view via the TOC and is taken to
the document. from there they click on a button on the page that is to print
out the document currently in view. However some of the documents have
overflown into two or more pages. Is there a way to build a function that the
document runs prior to the user clicking on the TOC so that the function
knows the number of pages assigned to each link in the TOC. That function
then passes the number of pages to the Application.PrintOut method to assure
that all the pages are printed?
I think the better way would be to set the argument in the PrintOut method to
print all pages. Show us the PrintOut method you have, currently, please? And
which version of Word is this?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Cameron

We are using Word 2003.

The reason I would like to count and locate the link a user clicks on in the
TOC is because there are a number of different articles under the TOC. A user
clicks on the hyperlink in the TOC, is taken to the article which can be one
or several pages long. The template used for these articles has a button on
it with code attached to print out the current page and also calls other
pages to print out. But when there is more then one page in the article often
the user has to scroll to the second page and press the button again, which
results in the current page being printed and a second set of the hyperlinked
pages. I do not think the intial developer of the template planned for the
articles to be anymore then one page long.

I kind of wish I could paste the word document here, it would be a bit
easier to explain how these templates where built to work.

I can paste the code for the button.


Private Sub CommandButton1_Click()
Application.PrintOut FileName:="", _
Range:=wdPrintCurrentPage, _
Item:=wdPrintDocumentContent, _
Copies:=1, _
Pages:="", _
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, _
Collate:=True, _
Background:=True, _
PrintToFile:=False, _
PrintZoomColumn:=0, _
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0

Application.PrintOut FileName:="", _
Range:=wdPrintRangeOfPages, _
Item:=wdPrintDocumentContent, _
Copies:=1, _
Pages:="2-4", _
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, _
Collate:=True, _
Background:=True, _
PrintToFile:=False, _
PrintZoomColumn:=0, _
PrintZoomRow:=0, _
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub

Private Sub CommandButton11_Click()
Selection.GoTo What:=wdGoToPage, _
Which:=wdGoToFirst, _
Count:=1, _
Name:=""
End Sub

Private Sub Document_New()

End Sub


The reason the previous developer used this template in this manner is that
the content of the articles are about safety proceedurers for the company. So
what happens is a user will pull the document from a file storage location
and open it. Inside the TOC they will locate the proceedure they will need to
use and click on the link. And then they will print out the proceedure and in
doing so linked attachments will also be printed for record keeping purposes.
But because some of the proceedures have spaned two or more pages, this
really complicated things.

It is advisable that the template documents not be seperated into more
documents, this has been suggested. And with nearly 200 documents now, having
to seperate pages from the documents because they spaned into two pages only
complicates locating the right document for the work to be preformed.

Cam
 
C

Cindy M.

Hi Cameron,

I don't know if you're still looking for help on this? I was away at the end of
June/beginning of July and am only just catching up...

I have an idea that might help: using some kind of identification system for
each button's "range" of text. For example, selecting the entire range of text
and assigning a bookmark. Then you should be able to dynamically get that
bookmark (and from that the range of pages you want to print) from the physical
location (range) of the button.

If that sounds reasonable to you, I'd need to know what kind of buttons these
are. Were they inserted from the Controls Toolbox (it looks like it)? Are they
position in-line with the text, or "floating" (with text wrap formatting)?

Does each article always start on a new page?
We are using Word 2003.

The reason I would like to count and locate the link a user clicks on in the
TOC is because there are a number of different articles under the TOC. A user
clicks on the hyperlink in the TOC, is taken to the article which can be one
or several pages long. The template used for these articles has a button on
it with code attached to print out the current page and also calls other
pages to print out. But when there is more then one page in the article often
the user has to scroll to the second page and press the button again, which
results in the current page being printed and a second set of the hyperlinked
pages. I do not think the intial developer of the template planned for the
articles to be anymore then one page long.

I kind of wish I could paste the word document here, it would be a bit
easier to explain how these templates where built to work.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Cameron

The button was inserted from the Controls Toolbox into the header of the
page. So it is always present on the page you are looking at. Each article
starts with a new page.

Will bookmarks still work with the button inside the header? This form was
orginially designed as a template and then any person could fill in the
ariticles with content, but as I have said over the course of time they have
overflown from one page to two. Intially I thought I could utilise the TOC
that was at the begining of each document. They are hyperlinked and come with
the page numbers, but have yet to figure out if I can read the page numbers
from the TOC. I had hoped to change the code under the button to have it look
for "trigger" in the content and determine page numbers prior to printing
out.

Hope you had a good vacation, thank you for your help.
 
C

Cindy M.

Hi =?Utf-8?B?Q2FtZXJvbg==?=,
Hope you had a good vacation
Wasn't a vacation, but thanks :)
The button was inserted from the Controls Toolbox into the header of the
page. So it is always present on the page you are looking at. Each article
starts with a new page.

Will bookmarks still work with the button inside the header? This form was
orginially designed as a template and then any person could fill in the
ariticles with content, but as I have said over the course of time they have
overflown from one page to two. Intially I thought I could utilise the TOC
that was at the begining of each document. They are hyperlinked and come with
the page numbers, but have yet to figure out if I can read the page numbers
from the TOC. I had hoped to change the code under the button to have it look
for "trigger" in the content and determine page numbers prior to printing
out.
Are you sure it's in the HeaderFooter story? Or is it just positioned over that
area? If it were in the header/footer story the user would have to double-click
in the story before they could access it, which I'd find rather odd...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Cameron

Yes the button is positioned over the boarder between the header and the
form. So it is foating on the pages.

Was just talking with the fellow that uses this template a lot and he said
the articles are getting longer then 2 pages now. So will need to make sure
the button's coding is capable of doing any number of pages.

Hope the bookmark things works. Would you have an example of how bookmarks
might work? Is the Table of Contents a kind of book mark also?
 
C

Cindy M.

Hi Cameron,
Yes the button is positioned over the boarder between the header and the
form. So it is foating on the pages.

Was just talking with the fellow that uses this template a lot and he said
the articles are getting longer then 2 pages now. So will need to make sure
the button's coding is capable of doing any number of pages.

Hope the bookmark things works. Would you have an example of how bookmarks
might work? Is the Table of Contents a kind of book mark also?
OK, a floating button is a Shape. And a Shape is always anchored to a
paragraph. So through that we can access things we need.

We still have to figure out the most efficient way for you to set this up.

There's one additional bit of information I need, and I don't want to make any
assumptions. So pardon what may seem to be a question I've already asked: Is
there a Page Break between each article? Or is it a Next Page type of section
break? Or do the articles start with a paragraph that has "Next page"
formatting?

I'd like to either make generating bookmarks automatic, or possibly avoid
having to use them altogether (maintenance if new articles are being added).
So it's important we can distinguish where an article actually STARTS and
ENDS.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
C

Cameron

It does not look like a page break is used to signify the end of a page but
rather a New Heading is used on the new page. And these headings coorpsond to
the table of contents which I might add I can click on to jump to the
particular pages in the document.
 
C

Cindy M.

Hi Cameron,
It does not look like a page break is used to signify the end of a page but
rather a New Heading is used on the new page.
OK, could you click in one of these headers, then go to Format/Paragraph. In
the "Line and Page Breaks" tab, is "Page break before" activated?

And is this formatted with a particular style? What's the style name?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
C

Cindy M.

Hi Cameron,
Page Break before is activated.

Paragraph Style is Heading 1
OK, a little late (I had to find a time frame where I could
set up a representative test), but the code below appears
to do the trick.

You'll notice that I have all the buttons call the same
procedure: PrintArticle. I don't actually have the PrintOut
method in there, but I do show you how to get the two page
numbers.

The "Information" property can return two types of page
number. "Adjusted" returns the page number you actually see
on the page if numbering is restarted, or different
numbering is used in different sections of the document
(like Roman numerals for the TOC, then restarting with
arabi numerals for the articles).

The Selection object being used is the button itself.

"\HeadingLEvel" is a built-in bookmark that picks up the
entire text from the Heading level of the current SELECTION
to the next instance of the heading level. You could run
into a problem here if, for some reason, the button is
anchored in text of a different heading level. Usually,
this wouldn't be the case. But if you see that only part of
a document is being picked up, check the anchor point of
the button and drag it up to the Heading 1 text.

Private Sub PrintArticle(Sel As Word.Selection)
Dim rng As Word.Range
Dim pageFirst As Long, pageLast As Long

Set rng = Sel.ShapeRange(1).Anchor
Set rng = Me.Bookmarks("\HEadingLevel").Range
pageLast = rng.Information _
(wdActiveEndAdjustedPageNumber)
rng.Collapse wdCollapseStart
pageFirst = rng.Information _
(wdActiveEndAdjustedPageNumber)
Debug.Print pageFirst, pageLast
End Sub

Private Sub cmdArticle1_Click()
PrintArticle Selection
End Sub

Private Sub cmdArticle2_Click()
PrintArticle Selection
End Sub

Private Sub cmdArticle3_Click()
PrintArticle Selection
End Sub

Private Sub cmdArticle4_Click()
PrintArticle Selection
End Sub


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 
C

Cameron

Interesting.

is there any manual or quick guide to allow me to leverage those keywords?
Would love to know.
 
C

Cameron

I am getting an error with the sel.Shaperang(1).anchor being out of range. I
have moved the button around a bit but it still gives me that error.

Also, the buttons that are at the start of each article are the same button
at the first article. Do they have to be different? is there a way I can send
you the example I got? Might clear things up on what is happening.
 
C

Cindy M.

Hi Cameron,
I am getting an error with the sel.Shaperang(1).anchor being out of range. I
have moved the button around a bit but it still gives me that error.

Also, the buttons that are at the start of each article are the same button
at the first article. Do they have to be different? is there a way I can send
you the example I got? Might clear things up on what is happening.
This last statement confuses me. I did ask specifically whether the button is IN
the header/footer, or positioned over the header/footer area. If the button is
"the same" for all articles then it can't possibly be a Shape on the document.

Is this a TOOLBAR with a button on it?

If that's the case, change that line of code to:
Set rng = Selection.Range
and see what happens.

(As soon as you send me files, and I open them, I charge consulting rates. Have
to draw that line somewhere...)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Cameron

Actually, I got the code working yesterday after I sent off the last reply. I
just commented out the Shape anchor line and bingo no more error.

I also managed to find a reference book, it is a little old but it had a
good explaination of how all the methods and classes work.

It is called Writing Word macros by O'reilly.

Thank you for all your help. :)
 

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