+ Reply to Thread
Results 1 to 5 of 5

Run a macro from another workbook

  1. #1
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Question Run a macro from another workbook

    Hi,

    Here is a code:

    Please Login or Register  to view this content.
    which opens the file, runs a macro in that file, saves it and closes it. But the problem is, it only does that for "FIRST\GRAND EVALUATIONS.xlsm" and then it stops running.

    Is there a way so that the file "FIRST - Copy\GRAND EVALUATIONS.xlsm" also opens,runs a macro named "Macro1", saves and closes itself?

    The file path of first "GRAND EVALUATIONS.xlsm" is C:\CALCULATIONS\FIRST\GRAND EVALUATIONS.xlsm
    AND
    The file path of second "GRAND EVALUATIONS.xlsm" is C:\CALCULATIONS\FIRST - Copy\GRAND EVALUATIONS.xlsm

    Despite having the same file name as well as macro name they both are in separate folders as stated above and also differ in every way, so each of them is expected to be opened, run a macro, save and close in their respective folders.

    Thank you

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Run a macro from another workbook

    Hi LAVA2,

    You seem to understand that Excel Macros are serial in nature. However, in addition to being serial, Excel Macros act like a 'daisy chain', and when the 'daisy chain' is broken (i.e. a file that is currently active in the 'daisy chain' is closed), all Macro activity in the 'daisy chain' stops.

    I can't say for certain what is happening without seeing a sample workbook of 'GRAND EVALUATIONS.xlsm'. My speculation is that 'Macro1' in that file closes workbook 'GRAND EVALUATIONS.xlsm'.

    I hope this helps. If you need additional help, please upload a sample workbook of 'GRAND EVALUATIONS.xlsm'.

    Lewis

  3. #3
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Run a macro from another workbook

    Hi LJMetzger .

    Firstly the code is supposed to open Macro1 of

    Please Login or Register  to view this content.
    and it does that.

    Secondly it was also expected to open Macro1 of


    Please Login or Register  to view this content.
    but it doesn't even open the file varNames2 = Array("FIRST - Copy\GRAND EVALUATIONS.xlsm").

    Please provide me with some solutions to solve this problem.

    Thank you

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Run a macro from another workbook

    My speculation is that the problem is not with the code you posted, but with the code in "FIRST\GRAND EVALUATIONS.xlsm". To come up with a definitive answer, you need to upload a sample workbook of "FIRST\GRAND EVALUATIONS.xlsm".

    Here is what you can do to try to debug the problem.
    a. To prove that the problem is in the subordinate workbooks replace "FIRST\GRAND EVALUATIONS.xlsm" and "FIRST - Copy\GRAND EVALUATIONS.xlsm" with workbooks of the same name with the following Macro Code:
    Please Login or Register  to view this content.
    If this runs to completion, and I think it will, go to the next step.

    b. Create a breakpoint in the real "FIRST\GRAND EVALUATIONS.xlsm" and "FIRST - Copy\GRAND EVALUATIONS.xlsm" at the start of 'Macro1'.

    Please Login or Register  to view this content.
    This should help you find the code that stops Macro execution. My speculation again is that it is a .Close statement somewhere.

    Lewis

  5. #5
    Forum Contributor
    Join Date
    12-02-2013
    Location
    england
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Run a macro from another workbook

    Thanks for you help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Personal Macro Workbook interference with other workbook macro(s)
    By Xanlithe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2015, 09:41 AM
  2. Replies: 1
    Last Post: 10-10-2015, 01:00 AM
  3. [SOLVED] VBA to open new workbook and run macro from new workbook, which closes old workbook
    By Rerock in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-26-2014, 10:45 AM
  4. [SOLVED] Macro to find data in source workbook and copy paste to target workbook
    By D.Lovell in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-23-2014, 06:21 AM
  5. [SOLVED] Save the split the workbook file type as Excel Binary Workbook From Run Macro
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-25-2013, 05:09 AM
  6. Replies: 9
    Last Post: 06-24-2013, 04:14 PM
  7. Replies: 0
    Last Post: 07-27-2011, 09:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1