G
Guest
Dear experts,
I locate a code to disable the copy and paste function in web for one of my
workbooks in Excel. After adding the code to the workbook module, it not only
disabled the copy and paste function of that workbook, it disabled all other
workbooks as well (including new workbooks). The disable including icons on
standard toolbar and right click menu. The function under Edit menu is still
OK. Even I deleted the code from the window module, I still cannot enable the
copy and paste function back. Any solution I can enable back the copy and
paste function except only that workbook. Please help and advise how. I list
the code below for your reference.
Thanks a million.
Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.OnKey "+{DEL}", ""
Application.OnKey "+{INSERT}", ""
Application.CellDragAndDrop = False
End Sub
Sub EnableCutAndPaste()
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
End Sub
Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
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
I locate a code to disable the copy and paste function in web for one of my
workbooks in Excel. After adding the code to the workbook module, it not only
disabled the copy and paste function of that workbook, it disabled all other
workbooks as well (including new workbooks). The disable including icons on
standard toolbar and right click menu. The function under Edit menu is still
OK. Even I deleted the code from the window module, I still cannot enable the
copy and paste function back. Any solution I can enable back the copy and
paste function except only that workbook. Please help and advise how. I list
the code below for your reference.
Thanks a million.
Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
Application.OnKey "^c", ""
Application.OnKey "^v", ""
Application.OnKey "+{DEL}", ""
Application.OnKey "+{INSERT}", ""
Application.CellDragAndDrop = False
End Sub
Sub EnableCutAndPaste()
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
End Sub
Sub EnableControl(Id As Integer, Enabled As Boolean)
Dim CB As CommandBar
Dim C As CommandBarControl
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