coding to close excel

spurs

Active Member
Joined
Oct 18, 2006
Messages
479
Office Version
  1. 2016
  2. 2013
  3. 2010
  4. 2007
  5. 2003 or older
Platform
  1. Windows
I am trying to get a macro to if necessary shut down the excel app where the macro itself is running from

Currently at the end of the macro, I have the coding:


Application.DisplayAlerts = False
ActiveWorkbook.Close

10 End Sub

The problem is that when this coding is reached, it does shut down the active workbook where the macro is contained
but
it opens a new blank workbook at the same time - which I don't want it to do
How do I avoid it from opening up a new workbook?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Do you have another macro in the Thisworkbook events?
I ask it because I did the test of your code, it closes the file and it does not open another file.

Try:
ActiveWorkbook.Close False
 
Upvote 0
this is what I have

Application.OnTime Now, "'" & ThisWorkbook.Name & "'!" & "Workbook_OpenStage2"


The macro Workbook_OpenStage2 is the macro I was referring to above
 
Last edited:
Upvote 0
Using
Try:
ActiveWorkbook.Close False

did not prevent a new workbook from opening
 
Upvote 0
Could you put your full macros?
That would help a lot.

This line is in an event?

Code:
[/COLOR][COLOR=#333333]Application.OnTime Now, "'" & ThisWorkbook.Name & "'!" & "Workbook_OpenStage2" [/COLOR][COLOR=#333333]

That line causes a new book to be opened, you have to clean the previous procedure using Schedule:=False








 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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