View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Using the OnTimer event to lock out users between specific time window.

Living the Dream formulated on Wednesday :
Hi guy's

Seems this may not be possible as yet no takers..

I was thinking along the lines of this, but unfortunately it does not
work, maybe someone could help steer me in the right direction
please..

Private Sub Workbook_Open()

Dim OpenTime As String
Dim resp As Long

OpenTime = Format(Now, "h:mm:ss AM/PM")

If OpenTime < #4:01:00 PM# #2:29:00 PM# Then

resp = MsgBox("YOU ARE NOT ALLOWED ACCESS BETWEEN 2.30 & 4.00PM
DAILY - PLEASE TRY LATER", vbOKOnly)
ThisWorkbook.Close SaveChanges:=False

End If

End Sub


It would so cool if Excel had the same BeforeOpen() function as does
Access...

In the event anybody happens to have a work-around for the above, I
will then need a way using VB to bypass the above so the main user who
requires unfetted access between the above times can access it.

Guy's

If this is pie-in-the-sky and not possible, please let me know and I
will stop wasting time on it and look for another alterative.

Appreciate any assistance or comments.

TIA
Mick.


Mick,
You need to use the *And* operand in your If...Then construct...

If (OpenTime < #4:01:00 PM#) And (OpenTime #2:29:00 PM#) Then

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion