+ Reply to Thread
Results 1 to 9 of 9

Code to prevent printing

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Ohio
    MS-Off Ver
    Microsoft 365
    Posts
    76

    Code to prevent printing

    Hello!
    Is there a code that can be input to prevent a document from being printed?

    Thank you!

  2. #2
    Valued Forum Contributor Miroslav R.'s Avatar
    Join Date
    05-16-2013
    Location
    NMnV, Slovakia
    MS-Off Ver
    Excel 2007
    Posts
    479

    Re: Code to prevent printing

    Hi there,
    of course there is... :-)

    See 'ThisWorkbook' events in VBA and You will find 'BeforePrint' event and with one row of code you disable printing:

    Please Login or Register  to view this content.
    Hope it helps
    Regards
    Miroslav R.

    (If You like my solutions, feel free to add reputation.)

  3. #3
    Registered User
    Join Date
    06-14-2012
    Location
    Ohio
    MS-Off Ver
    Microsoft 365
    Posts
    76

    Re: Code to prevent printing

    I went to the 'ThisWorkbook' in the VBA but I didn't see an option to (1) input a code for the Workbook (only the Worksheets) or (2) an option for 'BeforePrint'. The only options I see for printing is 'PersonalViewPrintSettings' with True or False as my selections. I'm a beginner with VBA so I know I'm probably looking in the wrong spot. Would you be able to be a little more specific on where I can find this setting and input the code?

    Thank you so much!!

  4. #4
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Code to prevent printing

    Just copy and paste the whole code in 'ThisWorkbook'.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Code to prevent printing

    What happens if a user doesn't enable macros?
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    06-14-2012
    Location
    Ohio
    MS-Off Ver
    Microsoft 365
    Posts
    76

    Re: Code to prevent printing

    Ok, I found where to input the code for ThisWorkbook and BeforePrint and then I saved it and closed the file; however, when I opened it back up, I was still able to print. Is there something else that I should be doing?

    Thanks!!

  7. #7
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Code to prevent printing

    Did you enable the macros?

  8. #8
    Registered User
    Join Date
    06-14-2012
    Location
    Ohio
    MS-Off Ver
    Microsoft 365
    Posts
    76

    Re: Code to prevent printing

    Ok, if I enable the macros the code works; however, due to security settings I'm not able to set a folder as a Trust Location on the shared drive where it's going to be housed for multiple user access, so, I'm thinking I'm just not going to be able to utilize it like I'd hoped. Thanks so much for all of the help!!!

  9. #9
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Code to prevent printing

    You can hide the sheets leaving a blank sheet with a message to enable macros, when you open the file you see only the sheet with the message and when you enable the macros it will unhide the other sheets and hide the sheet with the message. Just saying.

+ 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. VBA to prevent printing
    By debspears in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-10-2013, 09:33 AM
  2. How to prevent duplicate value printing ?
    By daksh1981 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-13-2010, 11:30 AM
  3. How to prevent printing
    By djeans in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2009, 08:03 AM
  4. How to prevent printing
    By giniyan in forum Excel General
    Replies: 2
    Last Post: 02-05-2009, 07:48 AM
  5. Replies: 2
    Last Post: 12-28-2006, 02:58 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