+ Reply to Thread
Results 1 to 5 of 5

How to create pop-up message in Excel before Printing

  1. #1
    ajay.pol@gmail.com
    Guest

    How to create pop-up message in Excel before Printing

    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. #2
    Kevin B
    Guest

    RE: How to create pop-up message in Excel before Printing

    YOu can use the Workbook_BeforePrint event, which is activate before print
    preview or before the document is sent to the printer.
    --
    Kevin Backmann


    "ajay.pol@gmail.com" 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. #3
    Otto Moehrbach
    Guest

    Re: How to create pop-up message in Excel before Printing

    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
    <ajay.pol@gmail.com> wrote in message
    news:1142890814.275802.87650@z34g2000cwc.googlegroups.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. #4
    Kevin B
    Guest

    RE: How to create pop-up message in Excel before Printing

    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


    "ajay.pol@gmail.com" 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. #5
    ajay.pol@gmail.com
    Guest

    Re: How to create pop-up message in Excel before Printing

    Hi Kevin,

    That worked beautifully!!
    Thanks for the code, and for saving trees!

    cheers
    123champ


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1