+ Reply to Thread
Results 1 to 2 of 2

BeforePrint command

  1. #1
    Registered User
    Join Date
    07-11-2021
    Location
    Maryland
    MS-Off Ver
    2019
    Posts
    6

    BeforePrint command

    I am trying to use the beforeprint command to hold printing and put up a message box. If the user answers YES, then printing can occur. Although I have used this before, I can't get it to run (yes the file is saved as macro enabled). I do not want to use a macro button. I just want the user to be notified after they hit file/print from the menu.

    Private Sub Workbook_BeforePrint(Cancel As Boolean)

    Dim Confirm As VbMsgBoxResult
    Application.EnableEvents = False
    Cancel = True
    Confirm = MsgBox("Are the dates and hours OK for your OT?", vbYesNo)
    If Confirm = vbYes Then ThisWorkbook.Print
    Application.EnableEvents = True
    End Sub

    Thanks

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: BeforePrint command

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Beforeprint event
    By DevilNava in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-21-2017, 02:44 PM
  2. If Command in BeforePrint
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-22-2009, 11:47 AM
  3. BeforePrint
    By Quail in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2009, 01:38 PM
  4. [SOLVED] BeforePrint help
    By Rookie 1st class in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2005, 06:00 PM
  5. [SOLVED] BeforePrint Event
    By Woody in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2005, 05:05 AM
  6. ThisWorkbook BeforePrint
    By Simon Shaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-12-2005, 02:05 PM
  7. ADO 2.7 & ADO 2.8 beforeprint
    By JCanyoneer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-30-2005, 12:06 PM

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