why close the open file after running the macro

Mussa

Board Regular
Joined
Jul 12, 2021
Messages
240
Office Version
  1. 2019
  2. 2010
Hello
I have problem about close the file where running the macro from it. actually I use this
VBA Code:
ActiveWorkbook.Close SaveChanges:=False
so far I don't find solution , any help please?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
This will quit the application, not just close the file. Equal to hitting the X in the corner of the window.

Try this:

VBA Code:
'sets the flag that the workbook is saved, doesn't save it
ThisWorkbook.Saved = True
Application.Quit
 
Upvote 0
sorry I wasn't clear from the beginnig .
I don't close the file at all , just keep the file is open.
 
Upvote 0
I'm not sure what you are trying to do. Are you just trying to close the file and leave Excel open? If so, the code you have works for me.
 
Upvote 0
Are you just trying to close the file and leave Excel open? If so, the code you have works for me.
absolutely not , the file xlsm contains macro when I run the macro should not close the file . just keep open
 
Upvote 0
Then remove that line. The file will then stay open.
 
Upvote 0
actually I did it , that's why I post here to solve this strange problem . I'm too lost !!!:rolleyes:
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,864
Members
449,052
Latest member
Fuddy_Duddy

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