Consulting

Results 1 to 4 of 4

Thread: Workbook that forces users to enable Macros and automatically closes after some time

  1. #1
    VBAX Newbie
    Joined
    Sep 2017
    Posts
    3
    Location

    Workbook that forces users to enable Macros and automatically closes after some time

    Hi,

    so I made a Workbook that does 2 things:
    1. It forces users to enable Macros and
    2. It automatically closes after being inactive for a defined amount of time

    The idea behind this is that only one user at the time would be able to use this file and that the file will automatically close after a certain time of being inactive. This will be useful if someone forgets to close a Workbook after using it (which can occur really often).

    I found all of necessary Macros on the web. So what I basically did was that I joined all of these Macros in one Workbook (see attachment)

    I ran into one problem. That is, that the workbook still wants a conformation for saving before closing. This prevents the closure of the workbook. Is there a way I could adjust the Macros so that this problem wont occur anymore.

    Thanks in advance and Kind Regards,

    Ciril
    Attached Files Attached Files

  2. #2
    VBAX Regular 6StringJazzer's Avatar
    Joined
    Jun 2015
    Location
    Tysons Corner, VA, USA
    Posts
    10
    Location
    It is not clear what you are expecting since you have explicit code in Workbook_BeforeClose to prompt the user to save changes if there are unsaved changes. If you want to prevent your own code from prompting the user then simply save before closing in Module1:

    Sub CloseSave()
    
    
    If Timer - TheTime > 30 Then ' po 30ih sekundah bi se moral izklopit
          ThisWorkbook.Save '''' ADDED LINE
          ThisWorkbook.Close SaveChanges:=True
       '  ThisWorkbook.Close SaveChanges:=False
    End If
    
    
    End Sub

  3. #3
    VBAX Newbie
    Joined
    Sep 2017
    Posts
    3
    Location
    Quote Originally Posted by 6StringJazzer View Post
    It is not clear what you are expecting since you have explicit code in Workbook_BeforeClose to prompt the user to save changes if there are unsaved changes. If you want to prevent your own code from prompting the user then simply save before closing in Module1:

    Sub CloseSave()
    
    
    If Timer - TheTime > 30 Then ' po 30ih sekundah bi se moral izklopit
          ThisWorkbook.Save '''' ADDED LINE
          ThisWorkbook.Close SaveChanges:=True
       '  ThisWorkbook.Close SaveChanges:=False
    End If
    
    
    End Sub
    Thank you Simple, but great solution.

  4. #4
    VBAX Regular 6StringJazzer's Avatar
    Joined
    Jun 2015
    Location
    Tysons Corner, VA, USA
    Posts
    10
    Location
    You're welcome! Feel free to post back if you find it's not quite what you needed.

Posting Permissions

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