+ Reply to Thread
Results 1 to 8 of 8

Macro to shut down excel with warning message

  1. #1
    Registered User
    Join Date
    09-12-2007
    Posts
    22

    Macro to shut down excel with warning message

    Hi

    I know this has been asked before with many solutions, but I am unable to find the specific answer to what I need.

    I would like to have some VB code that prompts the user after 20mins of inactive use in an excel workbook that they have the option to either continue using the workbook "Yes/No". If "Yes" is selected then the counter resets itself to zero and recounts to 20mins allowing the user to continue working, but if the user is not at their desk and nothing is selected then the message will only appear for 30 seconds, save then close the workbook, allowing others to access it.

    I have found codes that do part of what I need but not exactly what I am after.

    Any help would be greatly appreciated

    Many Thanks

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Macro to shut down excel with warning message

    This end the application without warning!!
    Please Login or Register  to view this content.
    Please take time to read the forum rules

  3. #3
    Registered User
    Join Date
    09-12-2007
    Posts
    22

    Re: Macro to shut down excel with warning message

    Sorry, dont this really answers my question? I dont understand what you have put.

  4. #4
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Macro to shut down excel with warning message

    Sorry misread your request as the title was a bit different.

    I will think about it!

  5. #5
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Macro to shut down excel with warning message

    Ok, i have some code for you.

    This has many pitfalls and i recommend you fully understand whats happening, either by reading about it or asking.
    Be sure to create som errorhandling in your code!

    In "Thisworkbook"-code module you place this
    Please Login or Register  to view this content.
    Then in a module you place these two
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Then in each of your sheet code modules you place this

    Please Login or Register  to view this content.
    Whenever a user of the spreadsheet changes a value in the workbook the timer resets.
    If you have data that automatically updates, then place a "Application.EnableEvents" around it

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to shut down excel with warning message

    Maybe
    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

  7. #7
    Registered User
    Join Date
    09-12-2007
    Posts
    22

    Re: Macro to shut down excel with warning message

    Hi,
    Thankyou both for replying but unfortunatley neither of these actually worked...unless I am doing something wrong.

    RoyUK--Do I paste this code straight into a module? Or do I need to split any of the code and place in "This workbook"?

    Many Thanks

  8. #8
    Registered User
    Join Date
    09-12-2007
    Posts
    22

    Re: Macro to shut down excel with warning message

    I found this code elsewhere and it virtually does what I want but the only problem is that the warning message does not give the option to continue working on the sheet, it just shuts down after x amount of seconds! Does any know how to amend the code to add in the Yes/No buttons to give the option to reset the timer or just shut down, as it currently does...

    This Workbook
    Please Login or Register  to view this content.
    Module1
    Please Login or Register  to view this content.
    Thanks again.

+ 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