Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word: Print Button to Print this page and next 3 pages Only

Status
Not open for further replies.

ladyck3

Technical User
Jan 3, 2003
800
US
I know how to set up a Print button but I don't know how to write vba scripting.

Could someone please help provide help on how to code a print button so when it is selected, it will print the current page and the next 3 pages.

For instance... a Word Doc with a Monthly Calendar (12 pages) and I put a print button on each page... January's Print button will print Jan, Feb, Mar, Apr.

February's Print button will print Feb, Mar, Apr, May, and so on...

Is this possible? If so, please help!!

Thank you,


LadyCK3
aka: Laurie :)
 
How are the pages separated? Page breaks? Section breaks?

If they are Section breaks, it makes it much easier.

These buttons...what are they? How EXACTLY did you put them into the document? The Controls toolbar?

There is no such thing as a "print" button. There are command buttons, and they do what ever you tell them to do. That could be print, it could be display a messsage box with a joke...what ever you tell them to do.

faq219-2884

Gerry
My paintings and sculpture
 
I am wondering why you need to go through all the trouble of making 12 separate commandbuttons - one on each page. You could use something like:
Code:
Sub PrintThisAndThree()
Dim j As Long
j = Selection.Range.Information(wdActiveEndPageNumber)
   If j + 3 > ActiveDocument.Range _
        .Information(wdNumberOfPagesInDocument) Then
      MsgBox "Ummmm, there are not three more pages."
   Else
        Application.PrintOut FileName:="", _
           Range:=wdPrintRangeOfPages, _
           Item:= wdPrintDocumentContent, _
           Copies:=1, Pages:=j & "-" & j + 3
   End If
End Sub
This simply gets the page number of the selection - the page the cursor is on - and checks to see if there ARE three more pages.

If there are, it prints the current page, plus the next three.

If not, displays a message that there are not three more pages.

You could could set this up as a shortcut key, or ONE button on a toolbar.

faq219-2884

Gerry
My paintings and sculpture
 
I thought of the print button as a good idea... I really don't know how to go about it... its a matter of folks not wanting to have to select t print and then tell it which pages to print. I do not have the calendar but its a word doc and its 18 months... when they select to print, it is printing all 18 pages, of course....

Its an "EASY BUTTON" for Execs basically...

I put that code you wrote into the editor and its saved 'n all but I can't get the print button to work, again it was just a thought.

Bottom line, an email with instructions for the non computer literate is going out, telling how to select the specific pages to print... but I thought if I could offer a solution then I'd be the WOAH-MAN :)

I appreciate your efforts ....sorry to tease your brain cells....

I'm so not versed in VBA that if I had to edit it, not knowing the language, I'd probably mess it up anyway (insert defeatest attitude) its been a day... what can I say.

thank you though...
Laurie

LadyCK3
aka: Laurie :)
 
The code above was not for the commandbutton. It is just a macro. As I wrote, you could make it a keyboard shortcut, or put it up as ONE button on a toolbar. This is very easy to do.

The macro prints the page the cursor is one, and the following three pages (if there are three more pages).

Bottom line? You CAN offer a solution.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top