| Enable / Disable CommandBarControl |
|
|
| 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 |
|