PDA

View Full Version : Solved: Enable & Disable Macro



jammer6_9
05-23-2007, 01:07 AM
Can I disable macro in worksheet events?

jammer6_9
05-23-2007, 01:18 AM
?

Private Sub Worksheet_Deactivate()
ActiveWorkbook.RunAutoMacros (xlAutoOpen)
End Sub

Private Sub Worksheet_Activate()
ActiveWorkbook.RunAutoMacros (xlAutoClose)
End Sub

Bob Phillips
05-23-2007, 01:24 AM
What is the question regarding post #2?

jammer6_9
05-23-2007, 02:08 AM
I just tried to enter the code like that and it seems it doesnt work at all...

Bob Phillips
05-23-2007, 02:30 AM
Then I am confused. You ask about disabling macros, then show code to run macros.

What exactly are you trying to do?

jammer6_9
05-23-2007, 04:38 AM
I want to Disable Macros in a worksheet event if its possible?

Bob Phillips
05-23-2007, 06:18 AM
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.

johnske
05-23-2007, 02:04 PM
To disable event code use Application.EnableEvents = False (and don't forget to set it back to True later)

Jan Karel Pieterse
05-24-2007, 12:01 AM
Check out:

http://www.jkp-ads.com/Articles/NoEvents00.htm

jammer6_9
05-26-2007, 12:47 AM
I've got full of option,information,idea to take. Thanks people...