![]() |
Can I have a box appear to select the number of pages to print
Here is a twist on my challenge€¦ Someone helped me right the following code
that automatically selects the number of pages to print. Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim rng As Range Set rng = ActiveSheet.Range("S2") On Error GoTo XIT Application.EnableEvents = False Cancel = True ActiveSheet.PrintOut from:=1, to:=rng.Value XIT: Application.EnableEvents = True End Sub Here is the twist: Just as the contents of cell €śS2€ť in the above code determines how many pages print I would like to use a check box in the workbook to put a €śTrue€ť or €śFalse€ť in a cell, for example €śS1€ť that would disable the above code. End goal: Some users could ignore the check box and the worksheet would print as many pages as are indicated in €śS2€ť and the more advanced users could check the box, thus returning the print parameters to them€¦ enabling them to select any combination of pages to print. What do you think? "Jim Thomlinson" wrote: This code should be close. I was unsure if you meant pages or copies so you will have to fix the code a bit. It needs to be placed in the ThisWorkbook module (right click the Excel Icon in the top left corner and select view code). Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim intPages As Integer On Error GoTo ErrorHandler Application.EnableEvents = False Cancel = True intPages = InputBox("How many pages?", "Pages to Print") ActiveWindow.SelectedSheets.PrintOut From:=1, _ To:=intPages, _ Copies:=intPages ErrorHandler: Application.EnableEvents = True End Sub -- HTH... Jim Thomlinson "Husker87" wrote: I have a sheet with 3 pages. I would like a box to appear when they hit print that asks them how many pages they would like to print. Is that possible? |
All times are GMT +1. The time now is 03:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com