I can have multiple Excel 2010 instances open at once because I'm using VBA Excel 2010. I have workbook1 open in the current Excel app, and I need to import data from workbook2 (which is open in a different Excel app). I've discovered that, even if workbook2 is open in another Excel app, APPACTIVATE will tell whether it is or is not. If not open right now, it's simple... Within the present Excel application, I simply open workbook 2, get my data, update workbook 1, and then dismiss workbook 2. So if workbook2 is already open, I have to access it, retrieve my information, update workbook1, and leave workbook2 alone. Can I access the workbook2 app in any way?
Sub AppAct()
'Workbook (1): workbook.name="Book1"
'Workbook (2): workbook.name="Fuel2010I.xlsm"
'Workbook (2): workbook.fullname="C:\FltTools\Fuel2010I.xlsm"
'Sheets("FL") exists in Workbook (2)
'Sheets("S") exists in Workbook (1)
On Error Resume Next
AppActivate ("FUEL2010I.xlsm")
If Err.Number > 0 Then 'if workbook not already open, then open it and select sheet "FL"
On Error GoTo 0
Workbooks.Open Filename:="C:\FltTools\Fuel2010I.xlsm"
Sheets("FL").Select 'works fine
Else 'if the workbook is open, select sheet "FL"
On Error GoTo 0
Sheets("FL").Select 'Subscript out of range, I'm not talking with FUEL2010I.xlsm
End If
Sheets("S").select
End Sub
I've tried the code as above. The code does not switch to the workbook2 instance of Excel