I have 4 "subs" in the "ThisWorkbook" object in a file. The basically keep the user from being able to cut/copy/paste. There is an option button in a hidden sheet in the workbook. I would like to re-enable the copy/paste functionality when this is selected. I have it working within the workbook, but when the workbook is deactivated (i.e. a second workbook is opened), I cannot paste from this file into that one. If I comment out the code in the "Private Sub Workbook_Deactivate()" below, I can paste from this file into the other file. However, if I then close this file and hit control C in the other file it opens this file back up. How can I disable all vba code when I close this file or deactive it?
Thanks!
Private Sub Workbook_Open()
'When file opens the copy/past function is disabled and all files are protected.
Call ToggleCutCopyAndPaste(False)
Module2.ProtectALLSHEETS
Sheet20.Visible = xlSheetHidden
Sheet28.Visible = xlSheetHidden
Sheet20.Unprotect ("tg11bud")
Sheet20.OptionButton2 = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ToggleCutCopyAndPaste(True)
Application.EnableEvents = False
Application.ScreenUpdating = False
Sheet30.Activate
Module6.UnProtectIt
Sheet30.Range("C6:C18").EntireRow.Hidden = True
Module6.ProtectIt
Sheet9.Activate
Module2.ProtectALLSHEETS
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_Activate()
End Sub
Private Sub Workbook_Deactivate()
Call ToggleCutCopyAndPaste(True)
With Application
.CellDragAndDrop = True
End With
End Sub
Thanks!
Private Sub Workbook_Open()
'When file opens the copy/past function is disabled and all files are protected.
Call ToggleCutCopyAndPaste(False)
Module2.ProtectALLSHEETS
Sheet20.Visible = xlSheetHidden
Sheet28.Visible = xlSheetHidden
Sheet20.Unprotect ("tg11bud")
Sheet20.OptionButton2 = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call ToggleCutCopyAndPaste(True)
Application.EnableEvents = False
Application.ScreenUpdating = False
Sheet30.Activate
Module6.UnProtectIt
Sheet30.Range("C6:C18").EntireRow.Hidden = True
Module6.ProtectIt
Sheet9.Activate
Module2.ProtectALLSHEETS
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub Workbook_Activate()
End Sub
Private Sub Workbook_Deactivate()
Call ToggleCutCopyAndPaste(True)
With Application
.CellDragAndDrop = True
End With
End Sub