Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

Excel Macro

  • Please log in to reply



    New Member

  • Member
  • Pip
  • 2 posts
Would somebody tell me what is missing in this code? Thank you very much!

Dim bOK2Use As Boolean

Private Sub btnOK_Click()
Dim bError As Boolean
Dim sSName As String
Dim p As DocumentProperty
Dim bSetIt As Boolean

bOK2Use = False
bError = True
If Len(txtUser.Text) > 0 And Len(txtPass.Text) > 0 Then
bError = False
Select Case txtUser.Text
Case "cxcxax"
sSName = "Blah Blah Blah"
If txtPass.Text <> "EXXXXXX" Then bError = True
Case Else
bError = True
End Select
End If
If bError Then
MsgBox "Invalid User or Employee ID"
'Set document property
bSetIt = False
For Each p In ActiveWorkbook.CustomDocumentProperties
If p.Name = "auth" Then
p.Value = sSName
bSetIt = True
Exit For
End If
Next p
If Not bSetIt Then
ActiveWorkbook.CustomDocumentProperties.Add _
Name:="auth", LinkToContent:=False, _
Type:=msoPropertyTypeString, Value:=sSName
End If

Sheets(sSName).Visible = True <-- IT STOPS RIGHT HERE
Sheets(sSName).Unprotect (txtPass.Text)

bOK2Use = True
Unload UserForm1
End If
End Sub
  • 0




    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts
I figured it out. Thanks!
  • 0

Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP