View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Claus[_3_] Claus[_3_] is offline
external usenet poster
 
Posts: 40
Default 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" skrev i
en meddelelse ...

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