Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi All,
I have a huge file that consumes reams of paper when printed. So I want a message box to appear when people click on the print icon in Excel (or click on File Print or Ctrl-P), suggesting that they should only print relevant sections of the document. Can someone suggest some basic macro code to achieve this? Thanks! 123champ |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
YOu can use the Workbook_BeforePrint event, which is activate before print
preview or before the document is sent to the printer. -- Kevin Backmann " wrote: Hi All, I have a huge file that consumes reams of paper when printed. So I want a message box to appear when people click on the print icon in Excel (or click on File Print or Ctrl-P), suggesting that they should only print relevant sections of the document. Can someone suggest some basic macro code to achieve this? Thanks! 123champ |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You would use a Workbook_BeforePrint macro for that. You can write code in
that macro telling the user whatever you want. You can also cancel the print command in the same macro. Here is one suggested code: Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim Ans As Long Ans = MsgBox("It is recommended that you print only a portion" & Chr(13) & _ "of this workbook and not the entire workbook." & Chr(13) & _ "Do you want this print job to continue?", 4, "Continue Print?") If Ans = vbNo Then Cancel = True End Sub HTH Otto wrote in message ups.com... Hi All, I have a huge file that consumes reams of paper when printed. So I want a message box to appear when people click on the print icon in Excel (or click on File Print or Ctrl-P), suggesting that they should only print relevant sections of the document. Can someone suggest some basic macro code to achieve this? Thanks! 123champ |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This is a bit more illustrative than my previous post:
Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim YesNo As Integer YesNo = MsgBox("Only print relevant data. Do you wish " & _ "to continue?", vbYesNo, "Yo! What's Up") If YesNo = vbNo Then Cancel = True End If End Sub Press Alt+F11 to open the VB editor and if necessary press Ctrl+R to open the Project window. In the project window locate the VBA project for the current file and double click on the ThisWorkbook object (you might have to double click your way through the tree to display everything). In the code window on the right, drop down the list at the top of the screen that currently says General and select workbook, and then to the right of that, drop down the list and select the BeforePrint event. The code goes right here. -- Kevin Backmann " wrote: Hi All, I have a huge file that consumes reams of paper when printed. So I want a message box to appear when people click on the print icon in Excel (or click on File Print or Ctrl-P), suggesting that they should only print relevant sections of the document. Can someone suggest some basic macro code to achieve this? Thanks! 123champ |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Kevin,
That worked beautifully!! Thanks for the code, and for saving trees! cheers 123champ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Stop excel from dropping the 0 in the beginning of a number? | Setting up and Configuration of Excel | |||
Error message when using Excel to open text file | Excel Discussion (Misc queries) | |||
Removing Rows for Printing | Excel Worksheet Functions | |||
How do I create a List in Excel 2000 | Excel Worksheet Functions | |||
Excel error message | Excel Discussion (Misc queries) |