+ Reply to Thread
Results 1 to 7 of 7

How to open another workbook from a separate workbook and run a macro on the one opened

  1. #1
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    How to open another workbook from a separate workbook and run a macro on the one opened

    I am having trouble getting a macro on an .xlsm to work right so I am trying to do a run around and get what I need to be converted to an .xlsx.

    I have a workbook that exports a sheet and saves it as .xlsx file the code is
    It works great when using the macro on the same workbook.
    Please Login or Register  to view this content.
    Now I have separate workbook that when my macro runs on that sheet that it would open this other workbook and run the above code on that opened workbook.

    I tried using this but it does not work I put it above the other code
    Please Login or Register  to view this content.
    any thoughts

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: How to open another workbook from a separate workbook and run a macro on the one opene

    Quote Originally Posted by bdouglas1011 View Post
    How to open another workbook from a separate workbook and run a macro on the one opened
    Try
    Please Login or Register  to view this content.
    Where "Book1.xlsm" is the name of the workbook with the macro to run.

  3. #3
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: How to open another workbook from a separate workbook and run a macro on the one opene

    Tried but it opens and the just sets there it does not execute the export.

    Also the name of the workbook will always be different can the Book1 be changed to adjust to the newly opened files each time
    Please Login or Register  to view this content.

    automatically use the name of the file opened

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to open another workbook from a separate workbook and run a macro on the one opene

    Which workbook is the sub 'ExportToolRun' in?

    Is it in the workbook you are running the posted code from?
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: How to open another workbook from a separate workbook and run a macro on the one opene

    it is in the one that is being opened.

    In short I have 3 different workbooks with the same sheet names and formats ... after the workbooks are completed ...I would like to link all 3 to another sheet to combine and track data off a particular sheet within all 3 workbooks.

    I had no luck so I then I tried to just open the workbook and copy the data into my new one ...one at a time but that did not work either. (They are all .xlsm)
    So I tried doing it with each individual sheet exported and saved as an (.xlsx) and I could get that to work. It just takes a while to do all the steps.

    The only difference is the workbooks are (.xlsm) and the individual sheets are saved as .(xlsx)

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to open another workbook from a separate workbook and run a macro on the one opene

    Why not have the code in a totally separate workbook?

    You could also have code in that workbook that opens the other workbooks, runs the required code in them, saves them etc.

  7. #7
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: How to open another workbook from a separate workbook and run a macro on the one opene

    I have tried even having the code in my new workbook but after it opens the .xlsm workbook nothing else happens no code ever runs.
    I have a sheet that is what I am using until I get this working I could attach it and let you look at it. and the other workbooks. to see if you can understand it.
    and if you think it might work

+ 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. [SOLVED] Code to open a another workbook from a macro, but have it opened and not be the active
    By scottatbuckman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2014, 03:43 PM
  2. [SOLVED] If workbook is opened, simply don't ask to open it and keep running the macro
    By LewisM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-19-2014, 12:50 PM
  3. Use a macro to extract cell data from opened workbook to new opened workbook
    By BrianTFC in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2014, 01:35 PM
  4. Replies: 0
    Last Post: 04-26-2013, 03:40 AM
  5. Replies: 2
    Last Post: 04-12-2013, 07:56 PM
  6. Personal Macro Workbook in Windows/Office 2007 does not open when Excel is opened
    By Rachel716 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-11-2012, 02:01 PM
  7. Automatic open others Workbook when we opened the Master Workbook
    By antoni in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-28-2009, 10:03 PM
  8. Automatically open 2nd workbook when 1st workbook is opened
    By ajarratt in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 01-27-2005, 09:25 AM

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