VB disable copy/paste help!

cterjesen

Board Regular
Joined
Jun 23, 2003
Messages
119
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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top