![]() |
Disable Pasting into a Workbook
Hi
I have a workbook, Wb1. I would like to be able to copy from Wb1 and paste to any other Wb but disable pasting into Wb1. -- Cheers Scotty |
Disable Pasting into a Workbook
http://www.j-walk.com/ss/excel/faqs/protectionFAQ.htm
Regards, Ryan-- -- RyGuy "scottyboy" wrote: Hi I have a workbook, Wb1. I would like to be able to copy from Wb1 and paste to any other Wb but disable pasting into Wb1. -- Cheers Scotty |
Disable Pasting into a Workbook
I have compiled the below code, when i copy from wb1 and go to copy into wb2
paste option is not available unless i open a new excel session. Think it may have something to do with the clipboard. Any suggestions? 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 Private Sub Workbook_Open() Application.ScreenUpdating = False For i = 1 To Worksheets.Count Sheets(i).Visible = True Next i Sheets("Warning").Visible = xlVeryHidden Application.ScreenUpdating = True End Sub Private Sub Workbook_beforeClose(Cancel As Boolean) Application.ScreenUpdating = False For i = 1 To Worksheets.Count Sheets("Warning").Visible = True If Sheets(i).Visible = True And Sheets(i).Name < "Warning" Then Sheets(i).Visible = xlVeryHidden End If Next i Application.DisplayAlerts = False EnableCutAndPaste End Sub -- Cheers Scotty "ryguy7272" wrote: http://www.j-walk.com/ss/excel/faqs/protectionFAQ.htm Regards, Ryan-- -- RyGuy "scottyboy" wrote: Hi I have a workbook, Wb1. I would like to be able to copy from Wb1 and paste to any other Wb but disable pasting into Wb1. -- Cheers Scotty |
All times are GMT +1. The time now is 10:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com