Closed Thread
Results 1 to 9 of 9

Thread: Kicking Inactive users by auto closing workbook

  1. #1
    Forum Contributor
    Join Date
    03-23-2007
    Posts
    149

    Kicking Inactive users by auto closing workbook

    Ok here's an unusual one that I need to know if possible.

    I have a current workbook that is active most of the day. What I need is a macro or something that autosaves the workbook, then closes it if left idol for a period of time, say 15 mins.

    Or another slant on this action, if the workbook is left idol for X time then some sort of cover sheet opens to hide the workbook until a password is entered, similar to a windows screensaver type action

    Please if anybodys got any answers or other suggestions please let me know

  2. #2
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,010
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    03-23-2007
    Posts
    149
    ok tried this and cant seem to get it to work...(not brilliant with macros)

    Any chance I could mail you the file so you can have a look. (Too much info / size to post)

  4. #4
    Forum Contributor
    Join Date
    03-23-2007
    Posts
    149
    Ok tried a few things and think i got it working now...all but one thing.

    On closing it asks if i want to save instead of autosaving and closing

    Did I miss something

  5. #5
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,010
    Try this example

    VBA Noob
    Attached Files Attached Files
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  6. #6
    Forum Contributor
    Join Date
    03-23-2007
    Posts
    149
    Thanx for the help as always

  7. #7
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,010
    No problem

    Code used

    In a normal module

    Dim DownTime As Date
    
    
    Sub SetTime()
    DownTime = Now + TimeValue("00:00:20")
    Application.OnTime DownTime, "ShutDown"
    End Sub
    
    
    Sub ShutDown()
    ThisWorkbook.Save
    ThisWorkbook.Close
    End Sub
    
    
    Sub Disable()
    
    On Error Resume Next
    Application.OnTime EarliestTime:=DownTime, Procedure:="ShutDown", _
    Schedule:=False
    End Sub
    In ThisWorkbook

    Private Sub Workbook_Open()
    MsgBox "This workbook will auto-close after 20 seconds of inactivity"
    Call SetTime
    End Sub
    
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call Disable
    End Sub
    
    
    Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
    Call Disable
    Call SetTime
    End Sub
    
    
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target _
    As Excel.Range)
    Call Disable
    Call SetTime
    End Sub
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  8. #8
    Registered User
    Join Date
    12-02-2008
    Location
    England
    Posts
    1
    Hello, this is my first post.

    I use this code, but is there any way I can disable the warning without disabling the code?

    We all know it is going to close at work so we don't need the warning anymore, it is just an annoyance.

    Thank you.

  9. #9
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639
    Quote Originally Posted by PeteGriggs View Post
    Hello, this is my first post.

    I use this code, but is there any way I can disable the warning without disabling the code?

    We all know it is going to close at work so we don't need the warning anymore, it is just an annoyance.

    Thank you.
    Please read the Forum Rules & start your own thread with a link to this one
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

Closed 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.2.0