A password question

  • Thread starter Thread starter Andy Smith
  • Start date Start date
A

Andy Smith

Hi,
my office is currently using Windows NT, but within months Windows XP
will be used.

I've made a timewokbook and want to protect it in such a way that only
I or the employee can open it.

My idea is
a) All employees have his/her own genuine server user_name. I want to
use this in a verification test.
b) I'm the section leader and shall have right of admission to all
timeworkbooks. My server user_name should be entered in cell A1 in
Sheet1 in all timeworkbooks. Each time I try to open the timeworkbook
from my own computer, a macro should compare the value entered in cell
A1 with the server user_name entered in the login window when the
computer is restarted every day.
c) The server user_name for each employee should be entered in cell B1
in Sheet1, and only in the file he/she use. The macro should compare
the value entered in cell B1 with the ser user_name entered in the
login window when the computer is restarted every day. The purpose is
that he/she should not be allowed to open the timeworkbook belonging
to other employees.

Could this be done?

Sincerely
Andy-s
 
Mr. Erlandsend's site:
http://www.erlandsendata.no/english/vba/os/index.php

has code for username and computer name.

---------------
Another example

From: Trevor Shuttleworth ([email protected])
Subject: Re: Code to show login name
Newsgroups: microsoft.public.excel.programming
Date: 2001-01-16 12:54:01 PST



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

Sub GetUserNameTest()
MsgBox fOSUserName
End Sub

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
 
Back
Top