Scottyboy
04-03-2008, 05:17 AM
Hi
Does anyone know how to prevent the clipboard from emptying.
I would like wookbook users to be able to copy from the workbook into another workbook but not able to paste anything in.
I complied the below code, which sems to work but when the workbook deactivates it seems to clear the clipboard.
Can anyone help?:banghead:
Public Switching As Boolean
Private Sub Workbook_activate()
DisableCutAndPaste
Switching = True
End Sub
Private Sub Workbook_Deactivate()
EnableCutAndPaste
Switching = True
End Sub
Private Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, True ' 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
Private 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
Private 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
Does anyone know how to prevent the clipboard from emptying.
I would like wookbook users to be able to copy from the workbook into another workbook but not able to paste anything in.
I complied the below code, which sems to work but when the workbook deactivates it seems to clear the clipboard.
Can anyone help?:banghead:
Public Switching As Boolean
Private Sub Workbook_activate()
DisableCutAndPaste
Switching = True
End Sub
Private Sub Workbook_Deactivate()
EnableCutAndPaste
Switching = True
End Sub
Private Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, True ' 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
Private 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
Private 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