+ Reply to Thread
Results 1 to 7 of 7

Merge multiple instances of excel into a single instance

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    Mumbai
    MS-Off Ver
    MS Office 2010
    Posts
    15

    Merge multiple instances of excel into a single instance

    Hi,

    Is there a way to merge all open instances of the Excel application into the single instance from which macro is being run, without closing any of the files open across multiple instances?

    Reason for this requirement is that a 3rd party application opens these files in separate excel instances and runs a macro from one of the opened files while another file has an add-in which connects to a portal. Neither of these files can be closed while trying to merge these into a single instance.

    I am currently using Microsoft 365 MSO (Version 2312 Build 16.0.17126.20132) 64-bit and whatever code I use needs to be compatible with Excel 2016 32 bit version as well.
    Last edited by PariD; 02-01-2024 at 07:32 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,194

    Re: Merge multiple instances of excel into a single instance

    Quote Originally Posted by PariD View Post
    Is there a way to merge all open instances of the Excel application into the single instance from which macro is being run, without closing any of the files open across multiple instances?
    No.

    Excel instances are Windows processes and processes cannot be "merged." There is no such concept. Once there are multiple files open in their own instances of Excel, the only possibility is to close the files and then re-open them from the instance running the macro.

    The other possibility is to see if it's possible to manage how the third-party application is opening Excel and why it creates a new instance for each file. There may be a way to change that, but without a lot more information I can't say.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,545

    Re: Merge multiple instances of excel into a single instance

    PariD, I think you want to go the wrong way.
    It seems to me that you should build a collection of Excel instances and assign to variables those elements of the collection that you need. Later you will operate on these variables to refer to the actual file. Some hint may come from this thread, but pay attention to the objections of other people commenting in this thread.

    Artik

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,194

    Re: Merge multiple instances of excel into a single instance

    I answered the question exactly as asked without thinking about the big picture.

    If your macro needs to operate on files that are open in a different instance of Excel, it is possible to do that as described in Artik's link.

    (Generally when asking a question it is best to describe your situation and goal, rather than suggest how you think something should be done.)

  5. #5
    Registered User
    Join Date
    05-09-2012
    Location
    Mumbai
    MS-Off Ver
    MS Office 2010
    Posts
    15

    Re: Merge multiple instances of excel into a single instance

    Thanks Artik, and yes you are right... if merging all instances is not possible, I am also exploring in parallel how can these files that are in separate instances be easily reference and operated upon. Thanks for the link that might probably help me in that direction. Will explore and revert if I am able to get a solution. Thanks again!

  6. #6
    Registered User
    Join Date
    05-09-2012
    Location
    Mumbai
    MS-Off Ver
    MS Office 2010
    Posts
    15

    Re: Merge multiple instances of excel into a single instance

    Quote Originally Posted by 6StringJazzer View Post
    I answered the question exactly as asked without thinking about the big picture.

    If your macro needs to operate on files that are open in a different instance of Excel, it is possible to do that as described in Artik's link.

    (Generally when asking a question it is best to describe your situation and goal, rather than suggest how you think something should be done.)
    Thanks for the guidance...I do not have much control on the 3rd party app that opens these files in separate instances and was exploring the possibility of merging multiple excel instances into one which would have made life much easier but if that's not possible, an easy way of referencing all files will do as well and I will explore the kink provided by Artik!

  7. #7
    Registered User
    Join Date
    05-09-2012
    Location
    Mumbai
    MS-Off Ver
    MS Office 2010
    Posts
    15

    Re: Merge multiple instances of excel into a single instance

    Quote Originally Posted by Artik View Post
    PariD, I think you want to go the wrong way.
    It seems to me that you should build a collection of Excel instances and assign to variables those elements of the collection that you need. Later you will operate on these variables to refer to the actual file. Some hint may come from this thread, but pay attention to the objections of other people commenting in this thread.

    Artik
    Atrik, Thanks for nudging me in the right direction. The link you provided was extremely helpful in understanding how to reference workbooks in different excel instances, just as per my requirement. I also wanted to share another link that I came across in Excelforum which has comprehensive codes for all relevant use cases which might be of help to others, but the forum rules restricted me from sharing links, hence sharing a lead here - Search keyword: macro-to-close-every-workbook-in-all-excel-instances (refer to response by LJMetzger - his response also has a downloadable file embedded with the codes which I am sure would be useful to anyone who wants to dig deeper). Thanks again for your help...Cheers!

+ 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. Merge multiple excel files into single file as different sheets
    By saidineshbabu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2015, 12:38 AM
  2. [SOLVED] Copying single instances of multiple names
    By andrewc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-01-2013, 04:56 AM
  3. Crash Single Instance Multiple Documents
    By Phoenix5794 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-07-2012, 02:46 PM
  4. Multiple Instances to Single Instance
    By jcholla in forum Excel General
    Replies: 2
    Last Post: 11-16-2011, 04:22 PM
  5. Replies: 2
    Last Post: 11-09-2007, 07:54 AM
  6. [SOLVED] Find Multiple instances of Single Criterion in Row & Return To a Single Col
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 05-09-2006, 10:10 PM
  7. [SOLVED] Ensure single class instance but with multiple references to it
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2006, 04:10 AM

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