1

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.

1
  • 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
    Oct 26, 2012 at 16:26

2 Answers 2

3

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

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .