殘疾人複製粘貼正在與下面的代碼:禁止複製/粘貼在Excel
Option Explicit
Sub ToggleCutCopyAndPaste(Allow As Boolean)
Call EnableMenuItem(21, Allow)
Call EnableMenuItem(19, Allow)
Call EnableMenuItem(22, Allow)
Call EnableMenuItem(755, Allow)
Application.CellDragAndDrop = Allow
With Application
Select Case Allow
Case Is = False
.OnKey "^c", "CutCopyPasteDisabled"
.OnKey "^v", "CutCopyPasteDisabled"
.OnKey "^x", "CutCopyPasteDisabled"
.OnKey "+{DEL}", "CutCopyPasteDisabled"
.OnKey "^{INSERT}", "CutCopyPasteDisabled"
Case Is = True
.OnKey "^c"
.OnKey "^v"
.OnKey "^x"
.OnKey "+{DEL}"
.OnKey "^{INSERT}"
End Select
End With
End Sub
Sub EnableMenuItem(ctlId As Integer, Enabled As Boolean)
Dim cBar As CommandBar
Dim cBarCtrl As CommandBarControl
For Each cBar In Application.CommandBars
If cBar.Name <> "Clipboard" Then
Set cBarCtrl = cBar.FindControl(ID:=ctlId, recursive:=True)
If Not cBarCtrl Is Nothing Then cBarCtrl.Enabled = Enabled
End If
Next
End Sub
Sub CutCopyPasteDisabled()
MsgBox "Sorry! Cutting, copying and pasting have been disabled in this workbook!"
End Sub
但是當我雙擊進入一個單元格,然後我可以做任何事情有剪切,複製和粘貼。
如何禁用複製粘貼,甚至雙擊到單元格?
請,不要!複製粘貼是最支持的用戶操作。而且你可能不會阻止它 –
幾乎總是有黑客的方式來提取文本 –
是的,但我需要一段時間故意。上面的代碼正在工作。只有使用雙擊時我無法防止。通常它的顯示只有在雙擊單元格後纔會失效。 – user3766722