+ Reply to Thread
Results 1 to 6 of 6

Before print, cancel print and cancel copy/paste

  1. #1
    Claus
    Guest

    Before print, cancel print and cancel copy/paste

    Hi

    I need to protect classified content on a sheet from beeing printed and
    copied into antoher workbook.

    Is there a way to cancel print by using Before print ?

    How about the copy situation ?

    Regards,
    Claus



  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon Claus

    Why not use .pdf format? It is much easier to control and not circumvent the controls as easily as you can in excel?

    If you insist the code to stop printing is fairly simple:

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    MsgBox "This workbook cannot be printed"
    Cancel = True
    End Sub

    That should do the trick. Halting cut / copy and paste is not quite so simple as there isn't an event called when you try to execute this operation, and there are numerous ways to copy items to the clipboard (ctrl +c, rightclick menu, Edit > Copy etc). There is some code on Bastien Mensink's site, www.asap-utilites.com. I shouldn't reproduce the code here, and there isn't a direct link, so go to this site and click on Tips and Tricks in the left hand menu. Disable Cut and Copy is the twelfth item down in the list that appears.

    HTH

    DominicB

  3. #3
    Claus
    Guest

    Re: Before print, cancel print and cancel copy/paste

    Hi DominicB

    Thanks a lot, i got it working except the BeforeRightClick event. Any idea
    why it doesn't work?

    Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, Cancel
    As Boolean)
    ' Add this code in the Worksheet_BeforeRightClick event
    ' it will load every a user right-clicks on the specified worksheet

    'To disable the user from "right-clicking" on the userform,
    'and therefore not be able to cut, copy or paste
    MsgBox "Hallo"

    Cancel = True
    End Sub


    Regards,

    Claus

    "dominicb" <[email protected]> skrev i
    en meddelelse news:[email protected]...
    >
    > Good afternoon Claus
    >
    > Why not use .pdf format? It is much easier to control and not
    > circumvent the controls as easily as you can in excel?
    >
    > If you insist the code to stop printing is fairly simple:
    >
    > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > MsgBox "This workbook cannot be printed"
    > Cancel = True
    > End Sub
    >
    > That should do the trick. Halting cut / copy and paste is not quite so
    > simple as there isn't an event called when you try to execute this
    > operation, and there are numerous ways to copy items to the clipboard
    > (ctrl +c, rightclick menu, Edit > Copy etc). There is some code on
    > Bastien Mensink's site, www.asap-utilites.com. I shouldn't reproduce
    > the code here, and there isn't a direct link, so go to this site and
    > click on Tips and Tricks in the left hand menu. Disable Cut and Copy
    > is the twelfth item down in the list that appears.
    >
    > HTH
    >
    > DominicB
    >
    >
    > --
    > dominicb
    > ------------------------------------------------------------------------
    > dominicb's Profile:
    > http://www.excelforum.com/member.php...o&userid=18932
    > View this thread: http://www.excelforum.com/showthread...hreadid=398927
    >




  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Hi Claus

    Change your first line. Try this:

    Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    ' Add this code in the Worksheet_BeforeRightClick event
    ' it will load every a user right-clicks on the specified worksheet

    'To disable the user from "right-clicking" on the userform,
    'and therefore not be able to cut, copy or paste
    MsgBox "Hallo"

    Cancel = True
    End Sub

    HTH

    DominicB

  5. #5
    Dave Peterson
    Guest

    Re: Before print, cancel print and cancel copy/paste

    Your code worked ok for me when I put it in the worksheet module that I wanted.

    But I had macros enabled and events enabled.

    Are you sure both of those are true?

    ==
    ps. You may be able to stop a few people from doing what you want, but if the
    user disables macros when they open the workbook, or disables events (anytime),
    then you may have a sense of false security.

    If the data shouldn't be shared or printed or copied, then excel isn't the
    application you should use.

    All the things you do to stop these are easily overcome.

    Claus wrote:
    >
    > Hi DominicB
    >
    > Thanks a lot, i got it working except the BeforeRightClick event. Any idea
    > why it doesn't work?
    >
    > Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, Cancel
    > As Boolean)
    > ' Add this code in the Worksheet_BeforeRightClick event
    > ' it will load every a user right-clicks on the specified worksheet
    >
    > 'To disable the user from "right-clicking" on the userform,
    > 'and therefore not be able to cut, copy or paste
    > MsgBox "Hallo"
    >
    > Cancel = True
    > End Sub
    >
    > Regards,
    >
    > Claus
    >
    > "dominicb" <[email protected]> skrev i
    > en meddelelse news:[email protected]...
    > >
    > > Good afternoon Claus
    > >
    > > Why not use .pdf format? It is much easier to control and not
    > > circumvent the controls as easily as you can in excel?
    > >
    > > If you insist the code to stop printing is fairly simple:
    > >
    > > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > > MsgBox "This workbook cannot be printed"
    > > Cancel = True
    > > End Sub
    > >
    > > That should do the trick. Halting cut / copy and paste is not quite so
    > > simple as there isn't an event called when you try to execute this
    > > operation, and there are numerous ways to copy items to the clipboard
    > > (ctrl +c, rightclick menu, Edit > Copy etc). There is some code on
    > > Bastien Mensink's site, www.asap-utilites.com. I shouldn't reproduce
    > > the code here, and there isn't a direct link, so go to this site and
    > > click on Tips and Tricks in the left hand menu. Disable Cut and Copy
    > > is the twelfth item down in the list that appears.
    > >
    > > HTH
    > >
    > > DominicB
    > >
    > >
    > > --
    > > dominicb
    > > ------------------------------------------------------------------------
    > > dominicb's Profile:
    > > http://www.excelforum.com/member.php...o&userid=18932
    > > View this thread: http://www.excelforum.com/showthread...hreadid=398927
    > >


    --

    Dave Peterson

  6. #6
    Claus
    Guest

    Re: Before print, cancel print and cancel copy/paste

    Thank you Dominicb and Dave

    It's working. I've discussed the issues that Dave mentioned in his mail, and
    we've agreed that this will protect us better than nothing at all.

    It is as Dave says very difficult to protect data.
    The user can stop macros and events if they know how to, and they can always
    do PrintScreen or mails and so forth and so on.

    Apreciate your help

    Claus


    "dominicb" <[email protected]> skrev i
    en meddelelse news:[email protected]...
    >
    > Hi Claus
    >
    > Change your first line. Try this:
    >
    > Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal
    > Target As Range, Cancel As Boolean)
    > ' Add this code in the Worksheet_BeforeRightClick event
    > ' it will load every a user right-clicks on the specified worksheet
    >
    > 'To disable the user from "right-clicking" on the userform,
    > 'and therefore not be able to cut, copy or paste
    > MsgBox "Hallo"
    >
    > Cancel = True
    > End Sub
    >
    > HTH
    >
    > DominicB
    >
    >
    > --
    > dominicb
    > ------------------------------------------------------------------------
    > dominicb's Profile:
    > http://www.excelforum.com/member.php...o&userid=18932
    > View this thread: http://www.excelforum.com/showthread...hreadid=398927
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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