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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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