Hi,

I am using Microsoft Excel for Microsoft 365 MSO (Version 2312 Build 16.0.17126.20132) 64-bit and whatever code I use needs to be also be compatible with MS Excel 2016 32-bit version.

I have searched various forums to get an effective solution for working with multiple Excel files opened in separate Excel instances however have not found any easy and straight forward way of referencing and doing simple operations such as copy from excel in one instance and paste to another etc.

A 3rd party application is opening 2 excel instances with 1 excel file opened in one instance and 2 excel files in another excel instance. The 2nd instance has the .xlsm file which is supposed to have a macro that will do various operation such opening additional files, filtering, copying, pasting data etc from one file to another and then saving the files. Any new file that the macro opens, by default opens in the 2nd Excel instance and is easily referenceable using the filename however the 1 excel file which is opened in a separate instance is not referenceable using file name. I have tried the below but am getting an error...

Dim xlApp As Excel.Application
Dim Wkbk As Workbook
Dim Pth_new as string
Dim FileName3 as string

Pth_new = "C:\Users\XXXXX\OneDrive - XXXX COM PROD\Desktop\Samples\"
FileName3 = "Samples.xlsx" 'This is the file that is open in a separate instance
    
Set xlApp = GetObject(Pth_new & FileName3).Application    'I get a error on this line - Runtime error '432 - File name or class name not found during Automation operation 
Set Wkbk = xlApp.Workbooks(FileName3)