Can I disable macro in worksheet events?
Printable View
Can I disable macro in worksheet events?
?
[vba]
Private Sub Worksheet_Deactivate()
ActiveWorkbook.RunAutoMacros (xlAutoOpen)
End Sub
Private Sub Worksheet_Activate()
ActiveWorkbook.RunAutoMacros (xlAutoClose)
End Sub
[/vba]
What is the question regarding post #2?
I just tried to enter the code like that and it seems it doesnt work at all...
Then I am confused. You ask about disabling macros, then show code to run macros.
What exactly are you trying to do?
I want to Disable Macros in a worksheet event if its possible?
If you want to disable all macros in someone else's workbook, you have to open it with macros disabled. If you want to stop macros running from within your workbook, you will need to stop them manually, with some sort of flag setting. If you just don't want users to run macros from Excel, add Option Private Module at the start of the modules.
To disable event code use Application.EnableEvents = False (and don't forget to set it back to True later)
I've got full of option,information,idea to take. Thanks people...