Consulting

Results 1 to 5 of 5

Thread: Solved: How Can I Disable A Macro from Another WB?

  1. #1
    VBAX Contributor CaptRon's Avatar
    Joined
    Mar 2007
    Location
    Austin, Texas
    Posts
    141
    Location

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

    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
    Last edited by CaptRon; 08-15-2007 at 04:16 PM.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Ron
    If it's an Event macro then
    [VBA]Application.EnableEvents = False[/VBA] should do this.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Contributor CaptRon's Avatar
    Joined
    Mar 2007
    Location
    Austin, Texas
    Posts
    141
    Location
    It is an event macro and that little diddy worked just right. Thanks a million.

    Ron

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Happy tp help. Don't forget to reset it to true. This does not happen by default when the macro finishes.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Contributor CaptRon's Avatar
    Joined
    Mar 2007
    Location
    Austin, Texas
    Posts
    141
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •