PDA

View Full Version : Solved: How Can I Disable A Macro from Another WB?



CaptRon
08-15-2007, 02:25 PM
Is it possible to run a macro in one workbook that will temporarily disable or enable a known macro in another workbook?

I need to make a few minor but important formula adjustments to workbook I sent to the field. I want to create an Excel WB that will automate that process for the user. But first, it will have to disable at least one macro before any sheet protection is removed and the code runs to make the formula changes.

Thanks,

Ron

mdmackillop
08-15-2007, 02:38 PM
Hi Ron
If it's an Event macro then
Application.EnableEvents = False should do this.

CaptRon
08-15-2007, 04:15 PM
It is an event macro and that little diddy worked just right. Thanks a million.

Ron

mdmackillop
08-15-2007, 11:42 PM
Happy tp help. Don't forget to reset it to true. This does not happen by default when the macro finishes.

CaptRon
08-16-2007, 07:04 AM
Yes, I ended the macro with Application.EnableEvents = True to enable again the event triggered procedure in the workbook.

Just playing around with it, I discovered that if I did not reset it to true, even when I closed the workbook and re-opened it, the event macro was still disabled, as long as I did not close Excel. But if I closed Excel and then opened the the workbook, the event procedures were again enabled.

I think I see why. I must disable events in all open workbooks in the Application (Excel), otherwise the events would only be disabled in the active workbook and that's not what I'm after. I need them to be disabled in the other workbooks I am about to repair. Apparently, Excel resets events to true when it closes or opens.

Thanks again for your very timely assistance. I will have this little wb out to the field by this evening loaded with a macro that will repair the defects in the larger wb they are evaluating for me. You folks are just the best to help out and I sure appreciate it.

Ron