Copy and paste prevention
MZ Tools makes life easier for the Excel VBA coder
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Copy and paste prevention

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    99
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I have an excel file of 7000 rows and 10 columns of sensitive information. But can I do something in VBA or Excel to prevent and copying and pasting the cells to a new file when the file is open by a client? They can print screen is the only way to capture the information.

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You would have to disable all of the copy and paste commands from the menus using VBA. (this includes the commands on the right-click menu and the "Edit" menu) If you search the message board you should be able to find an example of something similar. I've seen this asked recently.

    You could also disable the CTRL+C and CTRL+V key combos using the VBA "Onkey" command. (See VBA help for details)

  3. #3
    MrExcel MVP Tom Urtis's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, California USA
    Posts
    11,136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Try pasting any or all this (depending on your level of desired control) into your workbook module. You don't need every Sub here, so pick and choose what works best for you.

    Keep in mind 2 points:
    (1) This will disable your Undo capabilities.
    (2) There is no such thing as an uncircumventable security measure. In other words, this code is not the be all end all...it will only stop your friends.

    ''''''''''''''''''''''''''''''''''''''''

    Private Sub Workbook_Activate()
    With Application
    .CutCopyMode = False
    .CellDragAndDrop = False
    End With

    Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    MsgBox "Right click menu deactivated." & vbCrLf & _
    "Cannot copy or ''drag & drop''.", 16, "For this file:"
    End Sub

    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Application.CutCopyMode = False
    End Sub

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Application.CutCopyMode = False
    End Sub

    Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    With Application
    .CellDragAndDrop = False
    .OnKey "^c", ""
    .CutCopyMode = False
    End With
    End Sub

    Private Sub Workbook_Deactivate()
    With Application
    .CellDragAndDrop = True
    .OnKey "^c"
    .CutCopyMode = False
    End With
    End Sub

    '''''''''''''''''''''''''''''''''''''''''

    _________________
    Tom Urtis

    [ This Message was edited by: Tom Urtis on 2002-03-20 05:16 ]

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com