Consulting

Results 1 to 6 of 6

Thread: disable print screen

  1. #1
    VBAX Regular
    Joined
    Jun 2008
    Posts
    22
    Location

    disable print screen

    Hi,

    I would want to know what is the code to disable print screen.
    I got the code to disable print

    Application.OnKey "^p", ""
    So what is the code for print screen?
    please assist me..thanks

  2. #2
    VBAX Regular
    Joined
    Dec 2004
    Posts
    92
    Location
    What print screen? You mean the screen that comes up when you use the file menu to print? To select the printer from a list, select the pages to print, how many copies, etc?

    You could just disable the print command in the File menu:

    [VBA]Application.CommandBars("File").Controls(15).Enabled = False[/VBA]

    The Print Preview command would be a work-around for that, so you could disable that too.

    [VBA]Application.CommandBars("File").Controls(14).Enabled = False[/VBA]

    If that's not what you're looking for then I don't understand, please explain.

  3. #3
    VBAX Regular
    Joined
    Dec 2004
    Posts
    92
    Location
    BTW, that code would go into the workbook class:

    [vba]Private Sub Workbook_Activate()
    Application.CommandBars("File").Controls(14).Enabled = False
    Application.CommandBars("file").Controls(15).Enabled = False
    End Sub[/vba]

    (your control numbers may be different depending on your version of excel.)

    I prefer to use WB_activate, rather than WB_open because if the user switches to a different workbook, those commands would still be disabled.

    Also the counterpart to that code, which is just as, if not more important than the disable, is the ENABLE portion.

    [vba]Private Sub Workbook_Deactivate()
    Application.CommandBars("File").Reset
    End Sub[/vba]

    Without this the buttons will be permanently disabled, even after you close the WB.

  4. #4
    VBAX Regular
    Joined
    Jun 2008
    Posts
    22
    Location
    the print screen i mean is....ctrl+prt sc.

    See attachment for example

  5. #5
    VBAX Regular
    Joined
    Dec 2004
    Posts
    92
    Location
    This is purely a guess as I can't see how to trigger the code, or why it's useful, but none-the-less...my guess:

    [VBA]Application.OnKey "^p"
    Cancel = true
    [/VBA]

  6. #6
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    bump
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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