avilik


How can I determine (in VBA) who the current user of the open Excel file on the network is




Re: Current user

João Rodrigues


Hi avilik,

try Application.UserName, or WorksheetFunction.Proper(Application.UserName)

If are working in a network, you can also use Environ("username").

This in a Win 2000 environment with Excel 2000.

HTH

Joao Rodrigues






Re: Current user

avilik

Thank you Joao for the quick answer.

However, this is not the right one.

I should describe the situation in more detail:

Let's say the user 'N' had open the 'L:\SomeFolder\ABC.xls' file from the shared folder in his/her PC.

At the same time I want to save my 'C:\EFG.xls' file as 'L:\SomeFolder\ABC.xls' file.

I know the way how to find out if the 'L:\SomeFolder\ABC.xls' file is open.

Now I need to know BY WHOM the 'L:\SomeFolder\ABC.xls' file is open.

For example, If you will try to save any Excel file as the file that is open by 'someuserlanid' you will get the "File in Use" message.

That message will display the following information:

"ABC.xls is locked for editing

by 'someuserlanid'

Open 'Read-Only' or, click 'Notify' to open read-only and receive

notification when the document is no longer in use."

So, the words "by 'someuserlanid'" is a part of the message I think is created by some API call.

The only parameter that is available for me is the PATH to the file which I am trying to replace.

Thanks again,






Re: Current user

João Rodrigues

Ahhhh !!!! That's one very old question!

Check out this link ...

http://exceltips.vitalnews.com/Pages/T0510_Who_Has_the_File_Open.html

and this one..

http://vbnet.mvps.org/index.html code/network/netfileenum.htm

I have been around this subject for years... 2 or 3!!

I haven't found a solution. I know that the API function NetFileEnum probably is the solution but, is only acessible by network admin privileges that i don't have. Or i don't know enough to implement it... so i'vd give up.

I wish best luck in your quest.

JR





Re: Current user

avilik

Thank you JR.

I know those links...

Unfortunately, I have only one parameter - file path.

Will try to look at other sources.