+ Reply to Thread
Results 1 to 20 of 20

Automatically Save And Close Workbook After Period Of Inactivity

  1. #1
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Question Automatically Save And Close Workbook After Period Of Inactivity

    I have a workbook that gets viewed/edited on different computers throughout our shop, and the situation often arises where someone forgets to close the workbook after they are done with it, which means if someone else at a different station tries to open it, they aren't able to do any editing.

    I'm wondering if a way I could solve this problem would be by having the workbook automatically save and close after two minutes of inactivity. I don't know if Excel supports this kind of function, but that's why I'm asking.

    Any ideas?
    There is so much good in the worst of us,
    And so much bad in the best of us,
    That it hardly behooves any of us
    To talk about the rest of us.

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Hello,

    Below is a link that provides a macro that will obtain the results you need.

    http://www.excelforum.com/excel-prog...-workbook.html

  3. #3
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Alright, thanks, that's definitely a big help - however, it only works as long as the dude who opened the workbook actually clicks somewhere first. Is there a way to make the workbook start the countdown once it's opened?

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    see if it helps you
    Attached Files Attached Files
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  5. #5
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    That certainly helps with closing the workbook, but it closes within thirty seconds of opening it even if there is activity.

  6. #6
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Did you open the attached zip file it isn't requiring me to click anywhere. I have attached the file and code that I found here.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    just removed the '
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Thank you both, rvasquez, I removed the message prompt, so perhaps that is why I need to click somewhere first to start the countdown.

    john55, that fixed that problem; however, the workbook doesn't automatically save now.

    I'm trying to figure out the best way to combine these two codes into one, I've attached both examples to demonstrate what I described above.
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Okay I removed the message prompt as well for you. Open the attached document and wait about 10 seconds and it will automatically shut down if you have no activity.

    Thanks!
    Attached Files Attached Files

  10. #10
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    That does it! Sweet, thank you so much.

  11. #11
    Registered User
    Join Date
    06-03-2013
    Location
    Greece
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Hello!How can a cell showing us the downtime meter?

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  13. #13
    Registered User
    Join Date
    09-04-2013
    Location
    Litchfield Ohio
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    I looked through this download and it works great. I am attempting to read the code so it can be applied to my situation. Maybe I'm missing a piece but will you please explain how the code works. Even if I copy/paste the sections I find it doesn't work. Sincerely & Respectfully, Rob (MrDude)

  14. #14
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Quote Originally Posted by mrdude70 View Post
    I looked through this download and it works great. I am attempting to read the code so it can be applied to my situation. Maybe I'm missing a piece but will you please explain how the code works. Even if I copy/paste the sections I find it doesn't work. Sincerely & Respectfully, Rob (MrDude)
    Same question as mrdude70. A copy and paste of this code in a macro-enable workbook module doesn't seem to work for me.

  15. #15
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,925

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Wedge120,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

  16. #16
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    protonLeah,
    No disrespect intended, but my question is simply about the code that the original poster is now using for his problem.

    The original poster received help from member rvasquez. I am asking for a little bit if "dissecting" of his code, if you will. I do not see how starting a new thread about this code benefits the forum more than having a constructive discussion in the thread from which it sprang.

    Maybe you misunderstood my question?


    edit: I guess the wording of my question lead you to believe I was asking about how to copy and paste code? I am sorry, that was not the intent of my question. I simply wanted to know how the code works, not how to copy and paste code into modules. Sorry for the confusion.
    Last edited by Wedge120; 09-05-2013 at 06:46 PM.

  17. #17
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Hello mrdude70 and Wedge120, I am not the most proficient at Excel coding, but let me see if I can help you out here.

    I just followed these steps to create another working copy of this code (and I changed the time value to 30 seconds to give you a bit more time to work with):

    1. Create and save a new Excel document as an Excel Macro-Enabled Workbook.
    2. With the new workbook open in Excel, press the Alt & F11 keys simultaneously.
    3. Ensure your Project Explorer is open - if it isn't, press the Ctrl & R Keys at the same time. Its default location for me is the left side of the screen.
    4. Right click the Excel document title in the Project Explorer and choose Insert/Module.
    5. Double-click the newly created module (the default name is Module1) to open its window.
    6. Copy and paste this code into Module1:
    Please Login or Register  to view this content.
    7. Double-click the ThisWorkbook icon in the Project Explorer and paste this code into its window:
    Please Login or Register  to view this content.
    8. Switch back to your Excel file (Alt & F11), save and close.

    When you open your Excel file again and do nothing for 30 seconds, it should save and close automatically. All the best!

  18. #18
    Registered User
    Join Date
    10-25-2013
    Location
    Austra;ia
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    Just wanted to clarify something - what if the workbook has been opened as read only and you only want the auto close code to run if it is opened for editing?

  19. #19
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Automatically Save And Close Workbook After Period Of Inactivity

    phas21, unfortunately I'm not sure how to do that, but I'm sure if you directly contacted one of the gurus who solved my issue (as I don't think they are monitoring this thread anymore), they would be happy to help you out.

  20. #20
    Registered User
    Join Date
    09-24-2013
    Location
    United States
    MS-Off Ver
    2007, 2010, 2013
    Posts
    7

    Red face Re: Automatically Save And Close Workbook After Period Of Inactivity

    Quote Originally Posted by rvasquez View Post
    Okay I removed the message prompt as well for you. Open the attached document and wait about 10 seconds and it will automatically shut down if you have no activity.

    Thanks!
    Thank you so much.. I know an old thread.. but awesome job. :-)

+ 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