Disable cut/copy of shape and images

abba83rho

New Member
Joined
Jan 21, 2010
Messages
2
Hi all,

I hope you can help me with this problem (I surfed a lot on the web but I couldn't find anything about it): I have to disable cut copy and paste in excel 2007 file expecially for images and shapes object. for istance, I want the user to be able to create an arrow, but I do not want him to cut, copy and paste it.

can it be done?

because office 2007 manages shapes differently from office 2003, and all the macros I have done so far work well with text but not with shapes.

thanks in advance

marco
 
Have had some luck with this code in the past, perhaps you'lll find something in it that you can modify for your needs:

Code:
Option Explicit
Private Sub Workbook_Open()
    DisableCopyCutAndPaste
End Sub
Sub DisableCopyCutAndPaste()
    EnableControl 21, False   ' cut
    EnableControl 19, False   ' copy
    EnableControl 22, False   ' paste
    EnableControl 755, False  ' pastespecial
    Application.OnKey "^c", "Dummy"
    Application.OnKey "^v", "Dummy"
    Application.OnKey "+{DEL}", "Dummy"
    Application.OnKey "+{INSERT}", "Dummy"
    Application.CellDragAndDrop = False
    Application.OnDoubleClick = "Dummy"
    CommandBars("ToolBar List").Enabled = False
End Sub
Sub EnableCopyCutAndPaste()
    EnableControl 21, True   ' cut
    EnableControl 19, True   ' copy
    EnableControl 22, True   ' paste
    EnableControl 755, True  ' pastespecial
    Application.OnKey "^c"
    Application.OnKey "^v"
    Application.OnKey "+{DEL}"
    Application.OnKey "+{INSERT}"
    Application.CellDragAndDrop = True
    Application.OnDoubleClick = ""
    CommandBars("ToolBar List").Enabled = True
End Sub
Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
  
On Error Resume Next
For Each CB In Application.CommandBars
    Set C = CB.FindControl(Id:=Id, recursive:=True)
    If Not C Is Nothing Then C.Enabled = Enabled
Next
End Sub
Public Sub Dummy()
    '// NoGo
    MsgBox "Sorry command not Available!"
End Sub
 
Upvote 0
No, unfortunately it doesn't work in 2007...

it's still possible to cut and copy pictures and shapes and also to cut-copy text via the button in the home ribbon : (

thanks anyway

marco
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top