irresistible007
Board Regular
- Joined
- Nov 24, 2005
- Messages
- 173
I am upto a project in Excel which will keep track of our company's expenses...
the file will only be accessible by pre-defined users, to access, the user will have to choose his username from a combo box and then will have to type the password (pre-defined too...) in a text box below, clicking OK will verify the info and will let him open the file... this whole thingy will be on a VB Form (logon Form)...
I want excel to hide all the sheets in background and only show the logon form at first, the sheets must only be visible upon successfull verification of user but close the workbook if failed...
prob is that excel comes up with the error saying " A workbook must contain atleast 1 visible worksheet... i have coded as below:
In thisworkbook:
In Logon form:
the file will only be accessible by pre-defined users, to access, the user will have to choose his username from a combo box and then will have to type the password (pre-defined too...) in a text box below, clicking OK will verify the info and will let him open the file... this whole thingy will be on a VB Form (logon Form)...
I want excel to hide all the sheets in background and only show the logon form at first, the sheets must only be visible upon successfull verification of user but close the workbook if failed...
prob is that excel comes up with the error saying " A workbook must contain atleast 1 visible worksheet... i have coded as below:
In thisworkbook:
Code:
Private Sub Workbook_Activate()
Sheets.Visible = False
logon.Show
End Sub
In Logon form:
Code:
Private Sub UserForm_Activate()
ComboBox1.Clear
ComboBox1.AddItem "User1"
ComboBox1.AddItem "User2"
End Sub
Private Sub cmd_ok_Click()
Dim myuser As String
myuser = ComboBox1.Text
Dim mypassword As String
mypassword = TextBox1.Text
If myuser = "User1" And mypassword = "Pass1" Then
logon.Hide
ElseIf myuser = "User2" And mypassword = "Pass2" Then
logon.Hide
Else: Workbooks.Close
End If
End Sub