+ Reply to Thread
Results 1 to 10 of 10

Excel vba close workbook after inactivity

  1. #1
    Registered User
    Join Date
    09-09-2003
    Location
    Australia
    Posts
    25

    Excel vba close workbook after inactivity

    Hi,

    I assume its possible with vba but not sure how to go about it.....

    I need a workbook to close after a period of say 5 minutes of inactivity. Sometimes the user will go into the file and forget about it when other users need to use it!

    does anyone have any code or suggestions?

    vaneagle

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You would need to use VBA,


    First of all set a time limit eg 5 minutes
    Please Login or Register  to view this content.
    This resets the timer if a change in the workbook occurs

    Please Login or Register  to view this content.
    If no changes have occurred then this runs
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-09-2003
    Location
    Australia
    Posts
    25
    I must be missing something.....

    Am I posting this in the module or ThisWorkbook??

    As it doesn't seem to work for me...

    Maybe its because its I have a 'Auto_Open()' sub as well?

  4. #4
    Forum Contributor boylejob's Avatar
    Join Date
    02-22-2007
    Location
    Forest City, NC
    MS-Off Ver
    2003
    Posts
    562
    vaneagel,

    Refer to this post.

    http://www.excelforum.com/showthread.php?t=600315

    This was posted a few days ago by royUK and it tells you where each section of code goes. You will actually be putting code in the ThisWorkbook, the Sheets, and the standard modules. Code must be put in all three places to get this to work. I have tried it and it works beautifully.

    Hope this helps!
    Sincerely,
    Jeff

  5. #5
    Registered User
    Join Date
    09-09-2003
    Location
    Australia
    Posts
    25
    You are correct!!

    It works great thanks All for your help!!

  6. #6
    Registered User
    Join Date
    09-09-2003
    Location
    Australia
    Posts
    25
    Update:

    For some reason the file once it is closed is reopening again..

    ie enable macros then the file pops up for a few seconds then closes again...

    weird....

    the zip file from this post:

    http://www.excelforum.com/showthread.php?t=600315

    does it as well....

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Add this right after the End With in Sub closeWB
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-11-2007
    Posts
    263

    Re: Excel vba close workbook after inactivity

    Quote Originally Posted by mikerickson View Post
    Add this right after the End With in Sub closeWB
    Please Login or Register  to view this content.
    I hate to ask, but what does this do? it looks like it sets the time value to 5:00 PM?

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Excel vba close workbook after inactivity

    It turns off the next OnTime event
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  10. #10
    Registered User
    Join Date
    03-02-2014
    Location
    Asia
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Excel vba close workbook after inactivity

    Noticed this code will not effect let say I edit or insert a comment in a cell and idle...it will not save and close but remain open...any idea? thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1