Application Quit closing down all instances of Excel

mark hansen

Active Member
Joined
Mar 6, 2006
Messages
484
I've been fighting with application.quit for a while now because it wouldn't close excel. I had this in the open even and first check to see if the user had read write privileges to a folder they will need for everything to work. I got that squared away by putting and Exit Sub after the Application.quit (if they fail the test to see if they have access).

Now I'm seeing the Application.Quit is closing ALL instances of Excel. So if the user is working on something, and opens one of my templates and doesn't have access... It will close down my Excel and then close the other one they had open without asking to save.

Is this normal or can I do something to just close down my instance of Excel?

Mark
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,561
Office Version
2016
Platform
Windows
How about closing the workbook only and not the whole application

Code:
ThisWorkbook.Close False
 

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
1,708
Office Version
2016
Platform
Windows
How about closing the workbook only and not the whole application

Code:
ThisWorkbook.Close False
Why do we use the false instead of true?

I have stambled at this for long. Have read some articles but don't seem to get the clear picture yet.

And what's the benefit of the close over the quit?
Regards
 

mark hansen

Active Member
Joined
Mar 6, 2006
Messages
484
Jaafar, I think that is what I'll need to settle with. Not idea, but better than shutting down any workbooks they may have open and not saved... I don't want to take anyone's work and throw it under the bus.

Kelly, closing leaves the Excel application open, without a workbook open, basically a grey screen where the user needs to take the extra step to close Excel. That's why I would prefer to quit Excel. In my file they bring up will not be saved anyway, its just a documentation template that sends their input out to a text file. In this case the text files goes to a secure folder. If they don't have access to the secure folder, no since filling out the template. I'm trying to reduce frustration, but if quitting Excel causes frustration by closing down their work, better to do what Jaafar says, just close the workbook.

Thanks for the Input Jaafar!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,967
Office Version
365
Platform
Windows
Is your code opening the file in a new instance of Xl? If what is that code?
 

mark hansen

Active Member
Joined
Mar 6, 2006
Messages
484
Fluff, I hadn't thought of that... Code isn't opening the XL file. They are opening up from SharePoint, however the same thing happens when opened from the desktop. The just double click on the file and it's open. When there is no other XL file open, there is only one instance of Excel... When there is another file open first, there are two instances of XL. Is there a way to force a completely separate instance of XL when opening a file, that won't cause the other instances of XL to close when Application.Quit is used?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,967
Office Version
365
Platform
Windows
I've never used sharepoint, so know nothing about it, but if I open multiple files from my hard drive I only get 1 instance of Xl running (albeit in multiple windows).
 

Forum statistics

Threads
1,086,096
Messages
5,387,807
Members
402,080
Latest member
scott2020

Some videos you may like

This Week's Hot Topics

Top