Thread: login username
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default login username

Hi,

The OPEN statement in this case doesn't physically open the file as you do
when you open (say) and Excel workbook it simply makes it accessible for
reading and writing depending on what access mode you set.


Mike

"Ranjit kurian" wrote:

Hi

its working fine(without opening my txt file)

actually i have saved my txt file in web server (URL;http://.........) so my
macro should check the name form web link behind


"Mike H" wrote:

Hi,

I think the code below will do what you want but a couple of cautionary
notes. Any macro based solution is dependent upon the user enabling macros
and if you want to see how difficult that is then Google it or search these
forums. In addition what is to stop someone editing you text file. If you're
tring to keep information confidential except for privileged users then this
isn't a solution many would have faith in.

Private Sub Workbook_Open()
usrname = Environ("Username")
Open "C:\users.txt" For Input As 1 'edit to your path/file
Do While Not EOF(1)
Input #1, authname
If authname = usrname Then
MsgBox "Hello " & usrname & " OK to open file"
GoTo 100
End If
Loop
Close #1
MsgBox " Not authorised"
ThisWorkbook.Close savechanges:=False
100:
Close #1
End Sub


Mike

"Ranjit kurian" wrote:

I have created a txt file which contain employees NT names

I need a macro, so that when ever the person try to open my excel file, it
should check the NT name of his/her in txt file,and if the NT name exist in
txt file he should be allowed to open my excel file...