coding to close excel

spurs

Active Member
Joined
Oct 18, 2006
Messages
433
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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,623
Office Version
  1. 2007
Platform
  1. Windows
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
 

spurs

Active Member
Joined
Oct 18, 2006
Messages
433
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:

spurs

Active Member
Joined
Oct 18, 2006
Messages
433
Using
Try:
ActiveWorkbook.Close False

did not prevent a new workbook from opening
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,623
Office Version
  1. 2007
Platform
  1. Windows
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








 

Watch MrExcel Video

Forum statistics

Threads
1,130,182
Messages
5,640,660
Members
417,159
Latest member
Mayozero

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
Top