+ Reply to Thread
Results 1 to 5 of 5

Macro to only Unhide sheets if macros enabled and force user out after period of inactivit

  1. #1
    Registered User
    Join Date
    02-27-2012
    Location
    Columbus
    MS-Off Ver
    Excel 2007
    Posts
    5

    Macro to only Unhide sheets if macros enabled and force user out after period of inactivit

    Hi,

    I need a macro to 1. only allow a user to unhide tabs only if macros are enabled and whiles file is opened force use out of file if inactive for 5 mins.. I found bits and pieces online, but having issues merging the two together..

    I would appreciate if someone can help with that.. 1. only unhide tabs when macros are enabled. and 2. save and close file after 5 mins of inactivity. Thanks in advance

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro to only Unhide sheets if macros enabled and force user out after period of inact

    If you set the sheet to veryhidden it can only be unhidden from with the vba editor,
    for example
    Please Login or Register  to view this content.
    Note - you don't need to turn macros on to unide it, but you do need access to the vba editor.

    For the second part, what do you class as inactive? not changing a cell? not moving the mouse? not changing the selected cell? not clicking within the excel environment? etc.

  3. #3
    Registered User
    Join Date
    02-27-2012
    Location
    Columbus
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro to only Unhide sheets if macros enabled and force user out after period of inact

    yudlugar


    I appreciate your assistance. Yes for the second part if the cell is not changed for perhaps 2 mins, I want the excel file closing. The file is a shared file and often I find that it is locked all the time and the person in it just has it opened.

    It would be nice if you can share a code that will take care of both issues.. that is only make sheets available when macros are enabled and 2. close out file after a certain period of inactivity (not changing cells). I thank you in advance

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Macro to only Unhide sheets if macros enabled and force user out after period of inact

    I would suggest doing this with an additional hidden sheet, call it timer_lock. Then have a worksheet_change event in every sheet that sets cell A1 of timer_lock equal to 1.

    Then use the ontime method to get a macro to check A1 of timer_lock every 2 minutes. If it is 1, set it to 0. If it is 0, close the workbook.

    This would look something like this:
    In every sheet object module
    Please Login or Register  to view this content.
    In a standard module:
    Please Login or Register  to view this content.
    Then in your workbook open module:
    Please Login or Register  to view this content.
    Out of interest what is the aim of doing this? Implementing this code seems a horrendously bad idea to me.

  5. #5
    Registered User
    Join Date
    02-27-2012
    Location
    Columbus
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro to only Unhide sheets if macros enabled and force user out after period of inact

    So the reason for this is.. This is a shared file where different departments share the same file and update tabs that they are responsible for. The issue we have been running into is that often when different people try to access this file it saids it is locked by another person and sometimes the person may be away from their desks on hours and thus makes it impossible for anyone else to edit. The solution i thought is to require all to enable macros so that we can have a time element to it to avoid file always being locked

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Force Macros Enabled on Workbook Open
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-10-2014, 05:42 AM
  2. Macro to unhide sheets IF macro is enabled and hard drive serial # match list of HD#
    By nikolaikolev in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2011, 01:50 PM
  3. Macro to force macros to be enabled and prevent saving
    By DeckyB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-31-2010, 04:04 PM
  4. Force Macro Enabled
    By oberon.black in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-21-2005, 11:05 PM
  5. [SOLVED] Macro to force Excel to close after a given timeframe of inactivit
    By bobm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2005, 10:05 PM

Tags for this Thread

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