PDA

View Full Version : Solved: Help on environ validation before opening file



VISHAL120
09-26-2011, 03:17 AM
Hi All,

I actually using the below codes to verify the username before the workbook open



Private Sub Workbook_Activate()
On Error Resume Next
' Worksheets("working").Activate

Dim sh As Worksheet
Dim USERS As String

Worksheets("<<Fleche>>").Visible = True
Worksheets("<<Fleche>>").Activate
'ActiveWindow.DisplayWorkbookTabs = False

'>>>>>>************BLOCK ACCESS TO FLECHE AS PER LOGGING NAMES DEFINED****************>>>>>>>>>>>>>>>

Select Case (Environ("username"))
Case "", _
"Vicks", _
"Peter", _
"Jhon2", _
"Pascal", _
"user"
' for more user need to come and add on the code.

USERS = Environ("username")
DOMAIN_FLECHE = Environ("userdnsdomain")

'Call unhide
Sheets("KLoading").Select
Range("Q12").Value = Environ("username")
Call Setup_Toolbar



Case Else
Sheets("<<Fleche>>").Activate
USERS = Environ("username")
DOMAIN_FLECHE = "ntserver"
MsgBox (USERS) + " <<No Access to this Fleche Progress; << Closing Down >>", vbOKOnly, "Fleche Progress Calculation"
Call Clear_Toolbar
'ActiveWorkbook.Save
ThisWorkbook.Close savechanges:=False
Application.EnableEvents = False
Application.Quit
End Select

''Application.CommandBars("LOADING").Enabled = True
Application.CommandBars("fleche").Enabled = True

Application.StatusBar = "Fleche Progress Calculation : Ready <<<Report>>>"
My problem is actually every time there are new user i have to go the code and add the user. how can i keep alll the user on a sheet say in sheet 1 column A and the access is check through the sheet before opening and also i can add user on the sheet instead going on the code.

I will be very much grateful for the help .

thanks in advance.

Bob Phillips
09-26-2011, 03:27 AM
Untested





Users = Environ("username")
If Not IsError(Application.Match(Users, Worksheets("Sheet1").Columns(1), 0)) Then

DOMAIN_FLECHE = Environ("userdnsdomain")

'Call unhide
Sheets("KLoading").Select
Range("Q12").Value = Environ("username")
Call Setup_Toolbar
Else

Sheets("<<Fleche>>").Activate
DOMAIN_FLECHE = "ntserver"
MsgBox (Users) + " <<No Access to this Fleche Progress; << Closing Down >>", vbOKOnly, "Fleche Progress Calculation"
Call Clear_Toolbar
'ActiveWorkbook.Save
ThisWorkbook.Close savechanges:=False
Application.EnableEvents = False
Application.Quit
End If

VISHAL120
09-26-2011, 04:21 AM
Hi Bob,

Thanks a lot its ok , it works well.