How many Instances of Excel are open

julhs

Active Member
Joined
Dec 3, 2018
Messages
471
Office Version
  1. 2010
Platform
  1. Windows
In Workbook1 in its “ThisWorkbook” module I have a “Workbook_Open” event that automatically opens Workbook2 (reference file) when Workbook1 is opened.

Question; are Wb1 and Wb2 open in the same instance of Excel or in 2 separate instances
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
VBA opens files in the same instance. The only way for it to open files in another instance is if you explicitly create a new instance of Excel in the code.
 
Upvote 0
Thanks for clarification Jeff.
Reason for query its I’m having an awful job in automatically CLOSING (via ” Wb1’s, ThisWorkbook” module) without leaving a completely “Blank” instance of Excel still open.

See here;
Auto Save and Close all open files

Thanks for clearing that up for me though.
Now case of going back and trying to deal with the Ghost/Blank instance.
 
Upvote 0
I think @rlv01's post in your referenced thread does most of what you need.

You seem to want to add something like this:
VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    MsgBox "do something"
    'https://www.mrexcel.com/board/threads/auto-save-and-close-all-open-files.1250117/
    'Call Close_All_Files_Save    ' <--- rlv01 post 5 without the ThisWorkbook lines x2 moved to below here
  
    ThisWorkbook.Save
    If Workbooks.Count = 1 Then Application.Quit
  
End Sub
 
Upvote 0
Alex, sorry for delayed reply
I’m struggling to implement your suggestion, could you be a bit more explicit?
 
Upvote 0
If your only issue is that when the macro workbook is closed Excel doesn't close then try copying the code in post #4 into the ThisWorkbook code module.
 
Upvote 0
Yes it is the only issue.
Gave it a quick try but but still no joy.
Have to go out for rest of day, will try/look at it again later.
 
Upvote 0
In Workbook1 in its “ThisWorkbook” module I have a “Workbook_Open” event that automatically opens Workbook2 (reference file) when Workbook1 is opened.

Question; are Wb1 and Wb2 open in the same instance of Excel or in 2 separate instances

Greetings julhs,

Given Alex's post #4 doesn't appear to work (at least as you incorporated it), and reference your initial question, put a Stop at the start of Workbook_Open and step thru the code until Workbook2 is opened. Then go to either workbooks' interface and look under View/Switch Windows. Are both workbooks available? Yes=One instance of Excel, No=Another instance of Excel was created.
 
Upvote 0
GTO
Did that.
At the “Stop”, Workbook1 was the only one showing in “View/Switch Windows” of Workbook1,
stepped into code and Workbook2 opened, at that point in EITHER Workbooks “View/Switch Windows” both Workbooks are showing.
 
Upvote 0
Please show us all the code you are using. Tell us what it's meant to do and what is actually doing.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top