Limit the time viewing a spreadsheet

  • Thread starter Thread starter Lynxbci3
  • Start date Start date
L

Lynxbci3

I want to make a sheet visible for a certain amount of time (15 mins
then to make it invisible (hidden). Is there a way of building in
timer to a spreadsheet
 
Try the below code unhides and hides Sheet2.

---------------
Paste all into a module
---------------
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long

Public TimerID As Long
Public TimerSeconds As Single

Sub StartTimer()
Sheets("Sheet2").Visible = True
TimerSeconds = 900 ' 15 mins in seconds
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub

Sub StopTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
Sheets("Sheet2").Visible = False
End Su
 
Do you want this for yourself or for other users?

For other users.........the StartTimer code would best be placed into
Workbook_Open code.

And hope that the user(s) do not disable Macros.

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top