Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Who Has the File Open?.

Who Has the File Open?

by Allen Wyatt
(last updated December 1, 2016)

3

Joe asked if there is a way to determine, in a macro, who has a particular workbook open. He thought about using the WriteReservedBy property, but it doesn't seem to have the information he needs.

Unfortunately, there is no way to determine this information from VBA—it just isn't accessible. The WriteReservedBy property doesn't show who has a file open; it shows who saved the workbook using a password. In other words, when someone saves a workbook with the option to have a password to modify it, the file is "WriteReserved." The WriteReservedBy property contains the name of the person that saved the file in the WriteReserved state.

If you only need to know the answer (about who has the file open) periodically, it is easiest to gather a list of the open file names, and ask the network admin to tell you who has them open—such information is maintained on the network and accessible to the admin.

Another potential solution is to add an AutoOpen macro to each workbook that writes a temporary file to disk that contains the name of the person opening the file. The macro would need to not only open the temporary file, but handle error conditions, such as a temporary file that is already open. The temporary file could then be accessed by other macros to see the name that it contains.

An additional place that may hold an answer is the VBNet site. The article at this page contains code that may be adaptable for the desired information:

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

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2492) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Who Has the File Open?.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Editing While Spell-Checking

When you run a spell-check on a document, you may end up seeing other things that need to be edited. Never fear; you can do ...

Discover More

Formatting Canadian Postal Codes

Postal codes in Canada consist of six characters, separated into two groups. This tip explains the format and then shows how ...

Discover More

Calculating TV Time

In some industries it is necessary to work with time resolutions of less than a second. If you need to keep track of such ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (menu)

Creating a CSV File

Need to get your data into a format that can be easily read by other programs? Chances are good that a simple CSV file will ...

Discover More

Changing Link References

If you use UNC paths in your links to external information, those paths may need to be changed at some point. You can easily ...

Discover More

Saving All Open Workbooks

Wouldn't it be nice to have a single command that would save each of you open workbooks, all at once? It's easy to do with ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two minus 2?

2016-12-01 11:54:05

LinearD

Working for a large company, we have many people jumping into a file at any given time. This became frustrating when I was trying update the workbook connections and not being able to save it. So I wrote two macros; one to log the users details to a text file using ENVIRON$(), and another that loops every minute or so and checks for a file called "force-close.txt" that was stored in another location. I just create the file with the same name when I need to and it forces the user to save a copy and close the file. A little inefficiant, but does the job.


2015-01-27 12:20:29

Wyatt S

I have written a macro that tells you who is in an XLSX file. I wrote a post about it here: https://bizintelsolutions.wordpress.com/2015/01/26/who-is-in-excel-xlsx-file/

-Wyatt


2014-10-16 11:06:18

shantaram


Hi,

How do we know that if anyone else open my excel sheet & close it without saving.

so how do we find out this person ?


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.