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 gt;gt; 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!
123champYOu can use the Workbook_BeforePrint event, which is activate before print
preview or before the document is sent to the printer.
--
Kevin Backmannquot; wrote:
gt; Hi All,
gt;
gt; I have a huge file that consumes reams of paper when printed. So I want
gt; a message box to appear when people click on the print icon in Excel
gt; (or click on File gt;gt; Print or Ctrl-P), suggesting that they should only
gt; print relevant sections of the document.
gt;
gt; Can someone suggest some basic macro code to achieve this?
gt;
gt; Thanks!
gt; 123champ
gt;
gt;
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(quot;It is recommended that you print only a portionquot; amp; Chr(13)
amp; _
quot;of this workbook and not the entire workbook.quot; amp; Chr(13) amp; _
quot;Do you want this print job to continue?quot;, 4, quot;Continue Print?quot;)
If Ans = vbNo Then Cancel = True
End Sub
HTH Otto
gt; wrote in message ups.com...
gt; Hi All,
gt;
gt; I have a huge file that consumes reams of paper when printed. So I want
gt; a message box to appear when people click on the print icon in Excel
gt; (or click on File gt;gt; Print or Ctrl-P), suggesting that they should only
gt; print relevant sections of the document.
gt;
gt; Can someone suggest some basic macro code to achieve this?
gt;
gt; Thanks!
gt; 123champ
gt;
This is a bit more illustrative than my previous post:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim YesNo As Integer
YesNo = MsgBox(quot;Only print relevant data. Do you wish quot; amp; _
quot;to continue?quot;, vbYesNo, quot;Yo! What's Upquot;)
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 Backmannquot; wrote:
gt; Hi All,
gt;
gt; I have a huge file that consumes reams of paper when printed. So I want
gt; a message box to appear when people click on the print icon in Excel
gt; (or click on File gt;gt; Print or Ctrl-P), suggesting that they should only
gt; print relevant sections of the document.
gt;
gt; Can someone suggest some basic macro code to achieve this?
gt;
gt; Thanks!
gt; 123champ
gt;
gt;
Hi Kevin,
That worked beautifully!!
Thanks for the code, and for saving trees!
cheers
123champ
- Jul 20 Thu 2006 20:08
How to create pop-up message in Excel before Printing
close
全站熱搜
留言列表
發表留言