LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default Add Code to File Opening Q

I have the following code which displays a sheet called E-Splash if
you are not a user listed in named range MyUsers

How can I add to this that a second condition would be applied that if
you are listed also in MyUsers2 then unless A1 in sheet E-Users is
within 35 days of Now() you can't access the file and a message as
follows appears "Time Expired, Please contact etc etc" This would also
mean that if you are in MyUsers and not in MyUsers2 you could access
the file not matter how far Now() is from A1

Thanks



Private Sub Workbook_Open()
Dim myArray As Variant
Dim arName As String
Dim ws As Worksheet
arName = "MyUsers"
myArray = ThisWorkbook.Names(arName).RefersToRange.Value
With Application
If IsError(.Application.Match(.UserName, myArray, 0)) Then
MsgBox "You are NOT Permitted to access this File " & vbCr & _
"" & vbCr & _
"Please Contact Joe Bloggs at " & vbCr & _
"" & vbCr & _
"ABC Inc +0099 1 234567"
Application.DisplayAlerts = False
ThisWorkbook.Close False
Else
For Each ws In Worksheets
ws.Visible = True
Next
Worksheets("E-Splash").Visible = False
Worksheets("E-Users").Visible = xlVeryHidden
Worksheets("E-Sum").Activate
Application.DisplayAlerts = True
End If
End With

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
opening an existing text file useing code ramki[_2_] Excel Programming 3 May 23rd 06 09:38 AM
macro code to change file-opening password arunjoshi[_18_] Excel Programming 1 June 16th 05 08:49 AM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 3rd 05 03:40 PM
VBA code halts after opening a file Bill in Inverness Excel Programming 7 February 2nd 04 12:41 PM
Troubles opening a CSV file from code Bas van Dijk Excel Programming 0 January 19th 04 01:21 PM


All times are GMT +1. The time now is 02:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"