check who has an excel file open

S

slymeat

I have a database that imports an excel worksheet as part of a vba function.

I have used other postings (notably Ken Snell's reply of 08/22/2005 to a
thread entitled "Check for open Excel workbook and then close it and Excel")
to get code that checks if the file is open before I start the import but my
query is slightly different , hence the new post.

The excel file I'm importing is on a network and my query is whether I can
retrieve the name of the person who has the file open as the company is quite
big and I'd like to be able to got to the person's PC if they've left the
file open on their PC and/or are not responding to a blanket email to a group
of people to shut the excel file. I'd prefer to go to the person's PC and
shut the file or get them to shut the file rather than close the file on them
and potentially cause their work to be lost.

If I try to open the excel file ordinarily (through Excel and not as part of
a VBA function) and the file is open, I get a message saying that the file is
use and it says the name of the person who has the file open. It gives an
option to open a copy of the file as read-only. Would it be possible to
retrieve the information (i.e name) on the user that has the file open from
this dialog pane/error message as part of the VBA function that Ken Snell
wrote in his reply described above?

I presume this error message/dialog pane is the same error that Ken Snell is
checking for in the code he wrote in the above posting (error num 70) and
maybe the code could be altered to provide the name of the person that has
the file open.
 
Top