+ Reply to Thread
Results 1 to 3 of 3

BeforePrint

  1. #1
    Registered User
    Join Date
    04-10-2009
    Location
    Phoenix, Arizona
    MS-Off Ver
    2003
    Posts
    7

    BeforePrint

    Hello,
    First, just let me say that this is my first post here, and any assistance is greatly appreciated. I'd prefer tips, rather than a copy & paste fix

    I'm working on a pretty simple code, but I'm completely boggled. My VBA knowledge is pretty limited, so I know that it's blatantly obvious what I am doing wrong, but I have been looking at it for too long to notice the error for myself . A quick forum search yielded little pertinent info, so I come here begging for help.

    I want my worksheet to require validation of entry data before printing, so I decided to use the "Workbook_BeforePrint" event, and display a simple dialog box with an "ok" or a "cancel" button as input options.

    The problem is that, as coded, "cancel" button does not cancel the print.

    Here is the sample code:

    Workbook_BeforePrint:
    Please Login or Register  to view this content.
    Userform
    Please Login or Register  to view this content.
    Thanks in advance for any assistance! I look forward to hearing from you.
    Last edited by Quail; 04-10-2009 at 12:59 PM. Reason: Grammar

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: BeforePrint

    Hello Quail,

    Welcome to the Forum!

    Remove your variable "CancelPrint" from where it is now and declare it in a Standard VBA Module.

    Adding a Standard VBA Module to your Project
    1. Open your workbook
    2. Press the keys ALT+F11 to open the Visual Basic Editor
    3. Press the keys ALT+I to activate the Insert menu
    4. Press M to insert a Standard Module
    5. Paste the code by pressing the keys CTRL+V

    The variable will now be visible to all parts of your code.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-10-2009
    Location
    Phoenix, Arizona
    MS-Off Ver
    2003
    Posts
    7

    Re: BeforePrint

    I knew it was obvious

    Thank you so much for your timely response!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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