+ Reply to Thread
Results 1 to 8 of 8

Opening a 2nd Workbook and Running Macro

  1. #1
    Forum Contributor
    Join Date
    04-30-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    113

    Opening a 2nd Workbook and Running Macro

    Hey everyone,

    I'm hoping someone can help me out troubleshooting some code I found online (from Ken Puls).

    Context:
    - I have 2 workbooks ('Master' and 'Dash'). The first ('Master') compiles and summarizes data and the second ('Dash') imports this summarized data and presents it in a more 'user friendly' format.
    - I have a series of macros that run in 'Master' and I have a macro in 'Dash' that imports from 'Master' to 'Dash'

    Purpose of desired macro:
    - I would like to integrate the macro that imports from 'Master' to 'Dash' (currently residing in the 'Dash' workbook) into the a macro in the 'Master' workbook.

    Solution so far (which results in an error):
    -The following code which I tried to run from 'Master' is intended to open 'Dash' and run its 'Exprt' macro. Unfortunately it results in an error ("Run-Time error '1004': Cannot run the macro [...] The macro may not be available in this workbook or all macros may be disabled") at this line:

    Please Login or Register  to view this content.
    The complete macro code is below:

    Please Login or Register  to view this content.
    Any ideas to fix this issue? I've tried a few variation of that line causing the error and nothing worked so far.

    Thank you,

    Goeff.

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Opening a 2nd Workbook and Running Macro

    perhaps
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Forum Contributor
    Join Date
    04-30-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Opening a 2nd Workbook and Running Macro

    Hi John55,

    Thanks for trying to help out. Unfortunately, I the same error...

    I'm not sure what it is that's wrong. I'll keep looking into it.

    Geoff.

  4. #4
    Forum Contributor
    Join Date
    04-30-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Opening a 2nd Workbook and Running Macro

    I've managed to get passed that error but then I encountered another error and the more I think about what I need the more I realized this one might not do the trick. I need a macro that will open another workbook and run a macro within that newly open workbook and I don't think this code does that...

    If you happen do know what code would do this, please share, otherwise no worries and good day!


    Geoff.

  5. #5
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Opening a 2nd Workbook and Running Macro

    wow, thank you!
    anyway....try http://www.vbaexpress.com/kb/getarticle.php?kb_id=279

    yeap, good day to you too!

  6. #6
    Forum Contributor
    Join Date
    04-30-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Opening a 2nd Workbook and Running Macro

    Thanks John. That was the code I tried actually. So you also think it's the code I need... Ok, I will go back to it and try to get running again!

    Cheers,

    Goeff.

  7. #7
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Opening a 2nd Workbook and Running Macro

    Goeff,
    if you replace your code (from the wkb where yr macro lives) with something very simple like
    Please Login or Register  to view this content.
    and then
    try the code you already tried and did not work as you expected you will see that it works, so I think the best way to get the desired result a test file with yr macro would be useful, perhaps someone help you.
    good luck.

  8. #8
    Forum Contributor
    Join Date
    04-30-2014
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    113

    Re: Opening a 2nd Workbook and Running Macro

    Hi John,

    Thanks for your advice. I created a test file to run the msgbox macro as you suggested and was able to correct the new issue that I had run into and the macro ended working fine. Unfortunately, the macro that I am calling up (in "Workbook 2") from "Workbook 1" is running into an error and I think it is because it this macro in "Workbook 2" was meant to be run when "Workbook 1" was closed.

    Basically, it think I need to fix this by reorganizing my macros! As it is, "Workbook 1" opens a macro in "Workbook 2" and this macro in "Workbook 2" tries to open "Workbook 1" to import some data but run's into a problem because "Workbook 1" is still open. It seems like a bit of a mess but my knowledge of excel vba is limited so this is what I've been dealing with :S

    Thanks again! I'll go and try to solve this new problem that came up...


    Geoff

+ 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. Running A Macro With Information From the Workbook On Opening The Workbook
    By Jaynestown in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-17-2013, 03:04 PM
  2. Automatically running a query and a macro when opening the workbook
    By MDNerey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2013, 07:34 PM
  3. Opening / Running VBA form via macro
    By English_Bloke82 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-25-2013, 12:49 PM
  4. Running a macro on opening a file
    By nieironisio in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-08-2008, 10:08 AM
  5. [SOLVED] Running macro upon opening workbook
    By don in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2006, 01:20 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