creating a username and password box

  • Thread starter Thread starter kil
  • Start date Start date
K

kil

do anyone know how to create a username/password box with
a userform in microsoft Excel, I tried creating one but
not able to get the excel to make decision of who is
accessing, I don't want to use excel protect book, where
it will exposed all my work to every user,


here is my cod

if txtname= user

then workbookfiance.activate


am I'm on the right track?
 
You will need to save the allowable users in a list somewhere and compare
the current user against that.

You can get the login user with

Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Public Function UserName() As String
Dim sName As String * 256
Dim cChars As Long
cChars = 256
If GetUserName(sName, cChars) Then
UserName = Left$(sName, cChars - 1)
End If
End Function

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.LeftFooter = UserName
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top