Run Macro Code From 1 Workbook In Another

  • Hopefully someone can help me with this issue, as I am now completely lost ...

    I'll try and explain it in simple terms..

    I have 3 workbooks:
    Workbook A
    Workbook B
    Workbook C

    These each have one macro:
    Workbook A - Macro 1
    Workbook B - Macro 2
    Workbook C - Macro 3

    I can run Macro 1 from A, obviously, I can run it from B, but not from C.
    I can run Macro 2 from B, again obviously, and I can run it from A, but not C.
    I can run Macro 3 from C, but I can't run any of the others from C.

    For some reason, whenever I try to run Macro 3 from either A or B, I get the error message:
    Run-time error '1004': Cannot run macro <workbook><macro>. The macro may not be available in this workbook or all macros may be disabled.

    The same error message appears if I try to run macro 1 or 2 from C.

    My code is exactly the same in all workbooks so I know it's not the code. I have enabled all macros so I know that the disabled part isn't true.

    Has anyone else ever came across this? Is there a tick box I have missed somewhere that does not let macros be run from another workbook?
    I am totally lost with this as I see no difference in workbook C that I do with any of the other two.

    Any help or input would be greatly appreciated.

    This is the only site I have posted on, but I have asked our IT team if they have ever came accross this and no-one had. I also checked the microsoft website for any help and found nothing on there that was related.

    Thanks in advance

  • Re: Running Code From Workbook 1 In Workbook 2


    have you tried stepping through Macro 3 with either WbA or WbB as the active workbook? This may identify which line is causing the problem. The only other thing that I can think of that would produce similar symptons is that you had 2 copies of Excel running, as opening a second Excel session would not allow access to macros available to the first session.



    Record A Macro.

  • Re: Running Code From Workbook 1 In Workbook 2

    Thanks for replying

    I have tried stepping through the code and it's only the line that calls the macro that is causing the issue. The code to call the macro is the same for all 3 workbooks, the only difference being the workbookname and macro.

    I'm using "WorkbookA.xlsm!Macro1"

    This works perfectly fine for workbook A & B, but C isn't wanting to play!

    They are all opened through the same copy of excel. Although 3 boxes appear on my task bar, if this was the issue then i'd be having the problem with A & B not just C.

    Thank you again for taking the time to look at this for me.[hr]*[/hr] Auto Merged Post Until 24 Hrs Passes;[dl]*[/dl]For the record I have managed to find a work around for this.

    In workbook C I used worksheet_change and had it watch Cell A1 for any changes, if the cell changes then it runs macro 3.

    Now from worksheet A & B, instead of trying to run macro 3 in workbook C, my code changes Cell A1 in workbook C, which then makes Macro 3 run.

    Not exactly a solution to my issue, but a workaround which works!

    If anyone else ever comes across the issue I had and manages to find a root cause, then I'd love to hear it!!

    Thanks again to anyone who has taken time to look into this, or even just read this.


  • Re: Run Macro Code From 1 Workbook In Another

    I'm a few years behind in this reply, but put apostrophe's around your file's name in your code:

    Application.Run "'Workbook A.xlsm'!Macro 1"

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!