Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wish to close an excel file automatically if there is no activity for 5 minutes. I have no knowledge how to go about it. I tried to find a answer on Internet but there is no clear answer.

share|improve this question
1  
The only way I can think to do this is to keep track of when the workbook was last used by setting a variable for basically any event... and then using Application.Ontime to have a sub that checks the date in the variable to see if it was last updated 5 or more minutes ago. This solution is far too involved for me to be willing to write it for you though... –  Daniel Cook Oct 26 '12 at 16:26

2 Answers 2

up vote 3 down vote accepted

Google for 'excel close idle timer'. There are multiple complete solutions out there. There's even a tutorial post on this: http://www.biz-development.com/Software&Utilities/9.6.Closing-Excel-File-After-Idle-Time.htm

-- jm

share|improve this answer

This can be done in VBA. I had done this once before with a shared workbook, but could not find the code I used. What I did find is the following;

Close Workbook after Inactivity

I tested it on my Excel 2010 and it works just fine.

Note: It is referring to the ThisWorkbook object where it says to

Place this in the Workbook_Open event

Keep in mind macros need to be enabled for this to work. Also, the worksheet_change sub needs to be on each sheet you are looking for changes. If not, it will close the sheet even if they are working on another sheet that doesn't have the code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.