Workbook that forces users to enable Macros and automatically closes after some time

xdciro

New Member
Joined
Dec 7, 2016
Messages
7
Hi,

so I made a Workbook that does 2 things:
1. It forces users to enable Macros and
2. It automatically closes after being inactive for a defined amount of time

The idea behind this is that only one user at the time would be able to use this file and that the file will automatically close after a certain time of being inactive. This will be useful if someone forgets to close a Workbook after using it (which can occur really often).

I found all of necessary Macros on the web (https://www.mrexcel.com/forum/excel...se-excel-file-after-some-time-inactivity.html, http://www.vbaexpress.com/kb/getarticle.php?kb_id=379)

So what I basically did was that I joined all of these Macros in one Workbook.

I ran into one problem. That is, that the workbook still wants a conformation for saving before closing. This prevents the closure of the workbook. Is there a way I could adjust the Macros so that this problem wont occur anymore.

Thanks in advance and Kind Regards,

Ciril
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi Ciril,

Add the code below in Workbook_beforeclose event

ThisWorkbook.Saved = True

Once Saved property is set to True, Excel responds as though the workbook has already been saved and no changes have occurred since that last save.


ALTERNATIVELY

This should work as well

Code:
<code class="x-hidden-focus">    Application.DisplayAlerts = False
    ActiveWorkbook.Close
    Application.DisplayAlerts = True</code>
 
Upvote 0
@Zubair Muhammad
Hi,

Yes but setting the Saved Property to TRUE will discard any changes made to the workbook which is not what is supposed to happen.
 
Upvote 0

Forum statistics

Threads
1,216,041
Messages
6,128,461
Members
449,455
Latest member
jesski

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