Closing VBA code

Gladme

New Member
Joined
Mar 8, 2018
Messages
18
Hello,

I have a workbook includes several macros. The file issupposed to be used in several computers with several users.
In order to force users to “enable macros”, I added aworksheet named “open & close”. There is a note in this sheet givesinformation to users to enable macros. I also have a VBA code for before closingthat hide all sheets except “open & close”. Using this before closing VBAcode the file always open and close in the same sheet.

I want to hide the Save/Don’t Save message at closing stage.There is no matter to save or not to save the changes because the file issupposed to be used for some reports. I added this code but it doesn’t work.
<code>SubCloseBook()</code>
<code> Application.DisplayAlerts = False</code>
<code> ActiveWorkbook.Close</code>
<code> Application.DisplayAlerts = True</code>
<code>End Sub</code>

I also added this code to before closing code and it didn’twork as well. I believe that combination of before closing and closing code cause the issue that still I get the save/don't save question box.

Could you please help me with this issue? I want to have acode to hide all sheets except one in closing stage and don’t display thesave/don’t save message. Both save and don’t save options work for me as adefault for closing and saving.
Many thanks in advance.

 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If the workbook has changes you will always get the msgbox to save. Save it, then close and you wont get messages.

if the macro is IN the workbook you are closing, ActiveWorkbook.Close ends the code and nothing runs after it. (but does work in Personal workbook)
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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