Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Who has file open?

Status
Not open for further replies.

jennuhw

MIS
Apr 18, 2001
426
0
0
US
Is there a way that I can find the username of the person that may have a file open? I have a script that checks to see if a spreadsheet is open then creates a msgbox if it is. I would like to have the username of the person with the file open in the message.
 
Hi jennuhw

The code below is what I used over an NT network to get the user login id of the person who accessed the spread sheet. Hope this can be of use

Craig
[bigglasses]
Private Sub getname_Click()
Dim userName As String

userName = CreateObject("Wscript.Network").userName

MsgBox userName

End Sub
 
I'm testing all of these suggestions. I will let you know what I find out! Thanks!
 
Here's another one...

MsgBox Environ("username")

works the same for quite a few environment variables.
 
Thanks for the suggestions. I either couldn't get them to work or it returned the wrong name.

userstatus I couldn't get to work. I tried:
ActiveWorkbook.UserStatus
user = ActiveWorkbook.UserStatus
and a couple of other things, but it errored on me everytime.

writereservedby Gave me the name of the person that last saved it as write reserved.

The script that protector posted gave me an ActiveX error.
Loomah's gave me my login name.

I am not sure if I didn't make myself clear when I posted my original message. I am wanting to return the name that shows in the box when someone else has a spreadsheet open. Such as: This file has been locked for editing by "Kelly" Any other ideas?
 
Oops, protector's script also gave me my login name not the one of the person with the spreadsheet open!
 
If you can't get the solution in this forum have you tried any others?

E.g. Microsoft's excel programmers newsgroup is what I always used to use. Others include vbcity.com, vb-world.net, mvps.org

I'm intrigued by this problem for some reason!! I've tried to work it out but all I can do is access properties of a closed file accross a network or any file locally.
 
If you do find the solution, would you mind posting it here so that I could see it too?

Anyway, I will still try to find an answer when I am free.
 
I will check into this further. I will let you all know what I find!
 
If the workbook is 'shared' (Tools-->Share WorkBook) then you could use the .UserStatus property else you'll get an error
 
I am not able to share this workbook because my code adds hyperlinks to the file. So, I had to 'unshare' it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top