How to close excel worksheet after 15 mins? once it opened

E

Eric

I am using Excel 2003.
Once I open a workbook, I would like to close it after 15 mins automatically.
Does anyone have any suggestions on how to code it in macro?
Thanks in advance for any suggestions
Eric
 
D

Dave Peterson

Saved from a previous post:

So you would want to force the user to close the file -- even though you don't
know if the current changes should be saved or discarded?

That sounds like a disaster for you, your co-worker, and your boss -- who's
going to be upset that something got saved that shouldn't have -- or 8 hours of
work was discarded and shouldn't have been.

I think that this is a training issue.

But if you look at Chip's site to see how to close a workbook after a given time
of inactivity.

http://www.cpearson.com/excel/TimedClose.htm

(I can't say how much I think that this is a bad idea!)
 
P

Peter T

Dave Peterson said:
Saved from a previous post:

So you would want to force the user to close the file -- even though you
don't
know if the current changes should be saved or discarded?

That sounds like a disaster for you, your co-worker, and your boss --
who's
going to be upset that something got saved that shouldn't have -- or 8
hours of
work was discarded and shouldn't have been.

I think that this is a training issue.

But if you look at Chip's site to see how to close a workbook after a
given time
of inactivity.

http://www.cpearson.com/excel/TimedClose.htm

(I can't say how much I think that this is a bad idea!)

I think you just did <g>

Peter T
 
E

Eric

When I edit the file, which usually take less than 30 mins, then I will save
and close it manually. On the other hands, I set schedule task to open
specific file at specific time for reading only, therefore saving it before
closing is good for me.
I don't know whether I work on this file or not, once this file opens based
on schedule.

Once this file is opened at 10 am, I am still working on this file for 45
mins, and finish at 10:46 am. This file should not be automatically saved
and close at 10:31 am, because it does not inactivity for 10 mins. On the
other hands, if this file is inactivity for 10 mins after 30 mins, the this
file should be saved and close at 10:56 am.
For example,
1) Once this file is opened at 10 am, it should be saved and close at 10:31
am and inactivity for 10 mins between 10:21 am and 10:31 am.

2) if file is inactive starting at 10:22 am, this file should be saved and
closed at 10:32, because it passes the first 30 mins and inactivity for 10
mins since 10:22 am.

3) if file is inactive starting at 10:36 am, this file should be saved and
closed at 10:46, because it passes the first 30 mins and inactivity for 10
mins since 10:36 am.

Does anyone have any suggestions on how to add this condition to macro coding?
Thank everyone very much for any suggestions
Eric
 
E

Eric

I find following codes to be useful, but there is some issue missing for
following combined conditions.

For example,
1) Once this file is opened at 10 am, it should be saved and close at 10:31
am and inactivity for 10 mins between 10:21 am and 10:31 am.

2) if file is inactive starting at 10:22 am, this file should be saved and
closed at 10:32, because it passes the first 30 mins and inactivity for 10
mins since 10:22 am.

3) if file is inactive starting at 10:36 am, this file should be saved and
closed at 10:46, because it passes the first 30 mins and inactivity for 10
mins since 10:36 am.

Does anyone have any suggestions on how to add this condition to macro coding?
Thank everyone very much for any suggestions
Eric


Private Sub Workbook_Open()
dTime = Time
On Error Resume Next
Application.OnTime dTime + TimeValue("00:30:00"), "CloseMe"
On Error Goto 0
End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)
On Error Resume Next
Application.OnTime dTime + TimeValue("00:10:00"), "CloseMe", , False
dTime = Time
Application.OnTime dTime + TimeValue("00:10:00"), "CloseMe"
On Error Goto 0
End Sub

Public dTime As Date
Sub CloseMe()
ThisWorkbook.Close
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top