+ Reply to Thread
Results 1 to 14 of 14

Never print worksheet

  1. #1
    Registered User
    Join Date
    06-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    90

    Never print worksheet

    I have a number of worksheets in my workbook, but one contains information that is only relevant when using a computer. How do I make it so it does not get printed when the WB does? I don't want to hide the WS.

    I am looking for something like
    Please Login or Register  to view this content.
    But I don't want to end the entire print, just not have the print capture that worksheet.
    Last edited by bcas77; 07-22-2013 at 10:38 AM.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Never print worksheet

    Hello bcas77,

    Could you be a bit more explicit please. Which Page or Sheet do you not want to be printed?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    06-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    90

    Re: Never print worksheet

    The Worksheet that I do not want printed is called HotKey Codes. It contains a list of all the Hotkeys I have assigned Macros to.

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Never print worksheet

    Hello bcas77,

    Then please try it like this:

    Please Login or Register  to view this content.
    Sample WorkBook attached.

    Also see the "Please consider" note at the bottom of this post.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    90

    Re: Never print worksheet

    Thanks! That should work

    Is there a way to do it via the normal print process though? The people who will be using it in the future may or may not know how to run macros, so I am hoping it'll be able to run in the background for them.

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Never print worksheet

    Is there a way to do it via the normal print process though?
    No. It cannot be done without VBA.

  7. #7
    Registered User
    Join Date
    06-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    90

    Re: Never print worksheet

    No, sorry I should've clarified. I meant is there any way to do it if I press ctrl + P or click the print button too? I'll be able to use it well, but a person who just wants to print it off will not think to check the macros before printing. Is there any macro I can make that will disallow printing of that one?

    One way I was thinking was if they hit print, make the hotkey codes sheet go invisible, and then after printing is completed have it be visible again? Can that work?

  8. #8
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Never print worksheet

    you could experiment with the Wordbook_BeforePring() event. Try this, seems to work on my end


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by GeneralDisarray; 07-24-2013 at 10:04 AM.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  9. #9
    Registered User
    Join Date
    06-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    90

    Re: Never print worksheet

    That works.... but why??? I see no reference to the HotKey Codes in it...?

  10. #10
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Never print worksheet

    Well, long story short, Excel gives you the ability to control what happens on certain "workbook events". When you print, there is a workbook event called BeforePrint that can be accessed in the code. Think of the event as something that happens whenever the action of printing is called upon - no matter how that action is initiated.

    If you add code to the BeforePrint event, that code will happen whether the user goes to File>Print or presses Cntrl+P. The Cancel=TRUE stops the users action from being handled in the normal excel way. Basically, by using Winon's code, you have handled how you want the workbook printed and you tell excel "cancel that command from the user please".


    Also, turning off events with "application.enableEvents = false" is important! Otherwise when Winon's macro executes the event will fire over and over....

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Never print worksheet

    I see no reference to the HotKey Codes in it...?
    It appears in the module of the Workbook as provided in Post # 4.

  12. #12
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Never print worksheet

    Sorry Winon, just jumped in here :D I think the OP was wondering with the macro was able to work when the user pressed Cntrl+P.

    All I did was ask the workbook_BeforePrint() event to launch your macro.

    Please Login or Register  to view this content.

  13. #13
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Never print worksheet

    Hello GeneralDisarray,

    No problem, you are welcome. I would have suggested the same as what you had done, but I was busy with another issue, before I could get back in here before you.

  14. #14
    Registered User
    Join Date
    06-05-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    90

    Re: Never print worksheet

    Awesome, thank you guys so much! Nice teamwork :P

+ 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. Replies: 0
    Last Post: 05-22-2013, 01:17 PM
  2. Randomly sample 30 columns from worksheet input and print them in worksheet Output
    By Savan87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-05-2012, 01:00 PM
  3. [SOLVED] Macro to print the current worksheet WITHOUT having Print Preview
    By terrydennis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2012, 11:00 AM
  4. VBA code to print several print areas in one worksheet
    By ABSTRAKTUS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2010, 03:24 PM
  5. [SOLVED] print different worksheet by pressing visible button on worksheet
    By CLR in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 07:05 AM

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