Partager via


The Definitive 'Locked File' Post (updated 8/23/2017)

Any veteran of Excel has probably seen the error very similar to the one below:

  File in Use
  Tester123.xlsx is locked for editing  by 'another user'.
Open 'Read-Only' or, click 'Notify' to open read-only and receive notification when the document is no longer in use.

Example:

Dealing with this can give anyone a major headache as it's often random and hard to reproduce at will. What makes resolving this particular problem difficult is that there are multiple causes for the problem, and thus multiple solutions. This article attempts to break the file locking problem down categorically so that it's easy to diagnose and fix. However, please understand that while I promise that I'd love to provide you with a fantastic list of everything that could ever fix this issue, I can't. Due to the many different environment configurations, as well as various software and hardware that can be involved, these steps may not work to resolve your issue or resolve your issue with a 100% success rate. These are only some suggestions for some of the most common things to look for and steps to try.

 

Things to do to resolve the problem

I. Ensure these rollup and updates for Windows are installed

Install the update in the following rollup and then install the three updates referenced in the rollup article (total of four updates).

Note: Before installing these updates you must first install SP1 for Windows 7 or Windows 2008 R2 (https://support.microsoft.com/kb/976932).

Rollup article:

Convenience rollup update for Windows 7 SP1 and Windows Server 2008 R2 SP1
https://support.microsoft.com/en-us/help/3125574/convenience-rollup-update-for-windows-7-sp1-and-windows-server-2008-r2

II. Install the latest Updates for Excel and/or Office

This is where you go to find cumulative updates that are available from the Microsoft Office team to fix reported problems:

https://technet.microsoft.com/library/dn789213

III. Turn off the Preview Pane, Details Pane and pop ups that show information about file and desktop items 

This is a problem that has been reported to affect Windows 7 clients only, not Windows XP. This has been found to be an issue for which both Office and Windows have released updates for. However, while much less frequent, we've seen occurrences where this step may still help. If you are fully updated for both Office and Windows, and can find no other reason or resolution to this issue but this does help, this may be your only solution.

In a Windows Explorer window, do the following:

1. Right click on the Start Button.
2. Click 'Open Windows Explorer'.
3. At the top left click Organize > Layout
4. Uncheck Details Pane and Preview Pane.

5. On a Windows menu, click on Tools > Folder Options.  In the box that opens up, click on the View tab.  Scroll down the list to “Show pop-up description for folder and desktop items” and clear the checkbox and then click OK.

In Excel:

1. Click File > Open
2. Click Organize > Layout
3. Uncheck 'Details Pane' and 'Preview Pane'

If Outlook is involved:

1. Open a new e-mail.
2. In the "Include" group, click Attach File.
3. Click Organize > Layout 
4. Uncheck 'Details Pane' and 'Preview Pane'.

IV. Add the OpLocks registry keys

Add the following two registry keys to the client machines and then reboot the system:

Key: HKEY_CLASSES_ROOT\CLSID\{993BE281-6695-4BA5-8A2A-7AACBFAAB69E}
Name: EnableShareDenyNone 
Type: REG_DWORD 
Value: 1

Key: HKEY_CLASSES_ROOT\CLSID\{993BE281-6695-4BA5-8A2A-7AACBFAAB69E}
Name: NoOpLock
Type: REG_DWORD 
Value: 1

Note: Both of the above keys must be added for this solution to work.

V. Install operating system updates

1. For Windows 7, Windows 7 Sp1, Windows Server 2008 R2 or Windows Server 2008 R2 SP1 -

"ERROR_SHARING_VIOLATION" error message in Windows XP or in Windows Server 2003 when you try to open a file on an SMB share on a server that is running Windows 7 or Windows Server 2008 R2"

https://support.microsoft.com/kb/2625434

2. For Windows 7, Windows Server 2008 R2

"Temporary files do not synchronize correctly to a non-DFS share on a server from a client computer that is running Windows 7 or Windows Server 2008 R2"

https://support.microsoft.com/kb/2434932

3. For Windows 7, Windows 7 Sp1, Windows Server 2008 R2 or Windows Server 2008 R2 SP1 -

"You cannot access a shared file by using the SMB Version 2 protocol because of a race condition in Windows Server 2008 R2 or in Windows 7"

https://support.microsoft.com/kb/2618190

4. Windows Vista, Windows Server 2008 -

"You share some files on a computer that is running Windows Server 2008 or Windows Vista. Some users try to access these shared files. In this scenario, the computer may restart unexpectedly. Additionally, you receive a Stop error that resembles the following: STOP 0x0000004E (0x0000009A,parameter2, parameter3, parameter4 )PFN_LIST_CORRUPT"

https://support.microsoft.com/default.aspx?scid=kb;EN-US;2447725

5. Windows Server 2003 -

"You have a shared file on a computer that is running Windows Server 2003, Two applications access this shared file concurrently. One application has write access to the file, and the other application has read-only access to the file.After both applications run for some time, such as several hours, the application that has write access cannot write data to the shared file, and this application receives the "Delayed Write Failed" error message. This problem causes data loss or data corruption in the shared file."

https://support.microsoft.com/kb/971295

VI. Use MSConfig to stop third party programs and services, including antivirus software

1. Go to START, and from the RUN line, type MSCONFIG and hit ENTER.
2. The System Configuration Utility will launch. On the General tab, click the Selective Startup option. Then uncheck the boxes labeled "Load Startup Items" and "Load System Services".
3. Click on the Services tab. Find the column header at the top labeled "Service" and left click that column header to sort these services in alphabetical order. Scroll down in the list and find a service called "Windows Installer" and click it so that it has a check in the square box.
4. Click Apply and when the changes are made, the OK button will read "Close". Click this button and you will asked to reboot the machine.
5. After the machine has restarted, click OK when the System Configuration Utility information dialog appears. If the System Configuration Utility itself appears, click the red X at the top right corner of the dialog box. If you are prompted to restart the machine, click the button labeled "Exit Without Restart".

This should get the machine into a state where third party and non essential programs are not started when the computer boots. This includes anti-virus software. Try accessing shared files with these programs shut off.

To get the machine back to Normal mode, open MSConfig again as in Step 1 and on the General tab click the

“Normal” startup option. Click Apply, the Close and reboot the machine.

In cases where the wrong user name is displayed in the file lock dialog

Sometimes where it says 'another user' it has the name of someone that didn't open the file or it has no name at all. Just a big ' ' where a name ought to be. Fear not, there is a fix for this problem. The flavor depends on whether you have Excel 2010 or Excel 2007. The below KB Articles contain hotfixes that address several issues, not just the file locked issue. But in the dialog of the article you will see this as one of the problem descriptions:

Assume that you have an .xls file that is protected by Information Rights Management (IRM) on a network share. When you open the file in Excel 2007, a File In Use dialog box appears. However, the dialog box does not display the correct name of the user who locked the file. Therefore, you cannot edit the file.

Understand that these fixes don't make the File in Use dialog go away, they just correct the problem of showing bogus user name information on the dialog itself.

Excel 2007 - https://support.microsoft.com/kb/2598133

Excel 2010 - https://support.microsoft.com/kb/2598143

 

Additionally, we have seen this issue when the owner file is not deleted from the directory upon closing the file. The file looks like ~file name.xlsx and contains the user information for who had the file open. . This can happen if something interrupts the process and breaks Excels connection with the file.

An example of this would be if a user had the file open from a server and the server was then rebooted. This causes the connection between the Excel application and the owner file to be broken. When the user then closes the file, Excel does not see the need to remove the owner file from the directory, and this results in the orphaned file. When another user later tries to open the same file from that same directory with the orphaned (~filename.xlsx) file, Excel refers to the existing owner file for the information to present to the user in the file locked dialog, resulting in the incorrect user information being presented. To resolve this issue, you need only to delete the orphaned ~filename.xlsx file from the directory.

 

Considerations for NetApps storage devices

Note: If the issue is only occurring when using a NetApp or other third party storage, we would recommend engaging the Support Team for the third party technology for additional troubleshooting and assistance.

 

We have seen cases involving the file locking issue when moving files to a NetApps storage device. First and foremost - update your NetApps device to the latest version. The file locking problems can be fixed just by updating the NetApps device to the latest version. If that fails or if you have the latest version, there are a couple of other things to try. This information was documented at https://netappsky.com/netapp-storage-management/cifs-performance-is-slow-after-investigating-performance-issues-cifs-considerations/ but has since been taken down.

I. Enable oplocks

Make sure that cifs.oplocks.enable is on. Oplocks (opportunistic locks) enable a CIFS client in certain file-sharing scenarios to perform client-side caching of read-ahead, write-behind, and lock information. A client can then read from or write to a file without regularly reminding the server that it needs access to the file in question. This improves performance by reducing network traffic. CIFS oplocks on the filer are on.  By default: You might turn CIFS oplocks off under the following circumstances otherwise, you can leave CIFS oplocks on. 

1. You are using a database application whose documentation recommends that oplocks be turned off.
2. The CIFS clients are on an unreliable network.
3. You are handling critical data and you cannot afford even the slightest data loss.

sasfiler*> options cifs.oplocks.enable on

Make sure that this option is set before the clients connect to the filer.   If they are already connected, do a cifs terminate and cifs restart on the filer.

sasfiler*> options cifs.neg_buf_size 33028

II. Set cifs.oplocks_opendelta

Change the cifs.oplocks_opendelta setting. Under certain workloads setting cifs.oplocks_opendelta to 0 can improve CIFS throughput performance by 3% to 5%. Again, if setting this value to 0 results in client disconnects, reset it to 8 (the default value).  Changing the delay time for sending oplock breaks.  If a client that owns a file oplock sends a file open request, it is temporarily vulnerable to a “race condition” that can occur if the storage system requests an oplock break. To prevent this condition, the storage system delays sending an oplock break according to the delay time value (in milliseconds) specified by the cifs.oplocks.opendelta option.   By default, the default delay time is 0 milliseconds. If your storage system must support some older Microsoft Windows clients, including Microsoft you can set the delay time to another value, such as 8. This means that after the storage system receives or responds to a request to open a file, the storage system will make sure that 8 milliseconds have elapsed before sending an oplock break to that client.   options cifs.oplocks.opendelta time Here, time is the delay in milliseconds.  Setting the cifs.oplocks.opendelta option postpones the sending of oplock break requests to clients that have just opened files. You must consult technical support if you are considering setting this value higher than 35.

sasfiler*> options cifs.oplocks_opendelta 0

sasfiler*> options cifs.oplocks_opendelta 8

For example, try adjusting cifs.oplocks_opendelta to a value of 66 (milliseconds)

You might also want to increase the delay time for sending oplock breaks if you see syslog messages similar to the following:

Mon Jan 21 15:18:38 PST [CIFSAdmin:warning]: oplock break timed out to station JOHN-PC for file \\FILER\share\subdir\file.txt

Considerations for Shared Workbooks 

The primary feature of a shared workbook is to allow multiple users to open and edit the files simultaneously. However, if you have chosen to share your workbooks using the 'Share Workbook' feature in the Review ribbon, you may still experience this type of behavior in particular scenarios due to the way in which Excel opens and saves files.

Examples of scenarios that users may experience a similar message using a [Shared] Excel file simultaneously:

Scenario 1:   User 1 opens the [shared] file. User 2 also opens the [shared] file at the same time as User 1.
Result:  A "file is locked" type of message will be provided.
Workaround:  An option to "Notify" the user when the file is no longer locked is presented. Choose this option and when the lock is released, the user will be able to then choose to open the file in edit mode.

Scenario 2:   User 1 saves the [shared] file. User 2 also saves the [shared] file at the same time as User 1.
Result:  A "file is locked" or "file is locked, try again later" type of message will be provided.
Workaround:  Wait a short period of time to allow the lock to release and try saving the file again.

 

Flowchart

The following is a flowchart put together by Kevin Sickler on the Microsoft Excel Support team. It gives direction to this complex issue. Click the picture below to see a larger view:

Comments

  • Anonymous
    January 01, 2003
    Nothing is actually locking the Excel file itself. It's the temp file that gets accessed by any number of programs, including third party programs. This KB Article might help: Description of the way that Excel saves files support.microsoft.com/.../814068

    • Anonymous
      October 26, 2016
      Ha, one of our users ran into this issue again today and I figured I'd come back to this post as I figured there would still be people posting info in the comments. This is interesting to read, and makes total sense, thanks for the input! For anyone out there still troubleshooting this, it still seems like the "Preview Pane" causes locks even with the most recent windows updates, as we have people have the issue, and turning it off fixes it, though it could be some other issue besides the original one, of the NetApp issues came back or something like that. Will - what do you do when you have users dealing with this? With the knowledge of the issue you have, I'm curious is all.Thanks!
  • Anonymous
    January 01, 2003
    When I open Excel file by double click on the file name I've the same error message. In my case the problem is that the owner file (~filename.xlsx) is not created because of some reasons. But I've found a workaround. If I right click on the file and choose "Open" then Excel starts, creates temporary file and then successfully opens the file without any errors.

  • Anonymous
    January 01, 2003
    Thanks for the post, just found this.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Very thorough. Nice !

  • Anonymous
    September 19, 2012
    I tried everything mentioned on this article, but the issue still there. I have server 2008 R2 SP1 server and windows 7 client.

  • Anonymous
    July 15, 2013
    You can also try "Long Path Tool" can simplify and probably end your problems in unlocking, managing and renaming files that appear to have a long filename.

  • Anonymous
    August 22, 2013
    Shouldn't we leave OpLocks on for Vista+ Offline Files feature as described here: support.microsoft.com/.../296264 (Under 'Summary' > 'Note for Vista')

  • Anonymous
    October 15, 2013
    We use Novell, so what actually fixed was that we turned of file caching

  • Anonymous
    October 30, 2013
    Hi I have came across this post in looking for an answer and for me the temp workaround of disabling the preview pane so far works. But is there an actual fix for this yet?

  • Anonymous
    November 12, 2013
    How do I unlock the read only in Excel on the Microsoft Office for Mac 2011?

  • Anonymous
    January 09, 2014
    Pingback from Opening Office files slow over network

  • Anonymous
    February 14, 2014
    An actual fix would be to identify the user that has the file locked so the second user can inquire if the file is needed any longer or left opened on the taskbar !!!!

  • Anonymous
    February 14, 2014
    An actual fix would be to identify the user that has the file locked so the second user can inquire if the file is needed any longer or left opened on the taskbar !!!!

  • Anonymous
    March 05, 2014
    The comment has been removed

  • Anonymous
    May 15, 2014
    Pingback from Excel Macro File Locked for editing | Jamleck

  • Anonymous
    May 20, 2014
    The comment has been removed

  • Anonymous
    June 06, 2014
    The comment has been removed

  • Anonymous
    July 07, 2014
    I have the exact problem: "An example of this would be if a user had the file open from a server and the server was then rebooted. This causes the connection between the Excel application and the owner file to be broken. When the user then closes the file, Excel does not see the need to remove the owner file from the directory, and this results in the orphaned file. When another user later tries to open the same file from that same directory with the orphaned (~filename.xlsx) file, Excel refers to the existing owner file for the information to present to the user in the file locked dialog, resulting in the incorrect user information being presented. To resolve this issue, you need only to delete the orphaned ~filename.xlsx file from the directory."

    However, I can't find where the orphaned ~filename.xlsx in the directory.

    We share couple of Excel worksheets in the office. The are reside on shared folder on the server.

    Please kindly show where on the server can the ophan files be?

  • Anonymous
    August 15, 2014
    In our company we have the same error with some Excel files / Users.
    For Example:
    There is one file uses by 20-25 Users.
    Since 2 Weeks they could not see who is locking the file, it only shows "another User".
    I found out that the lock/owner file has 0KB and no User information in it. That must be the problem.
    When I’m opening the Excel list, there is also a Lock file created, but with 1KB and my User Information.
    Then our Users see the message "Locked by “My Username”"
    But this problem is not exist with each excel list.
    That’s really very strange. Does someone have any ideas? (Windows 7 32Bit Office 2010)

  • Anonymous
    August 25, 2014
    The comment has been removed

  • Anonymous
    October 01, 2014
    One of the reasons we have found you get this error is if the Document has been marked as Final.

  • Anonymous
    October 14, 2014
    We started experiencing this problem after enabling the following registry settings on our file server:

    HKEY_LOCAL_MACHINESystemCurrentControlSetServicesLanmanServerParameters

    EnableOpLocks = 0
    CachedOpenLimit = 0
    EnableOpLockForceClose = 1

    SharingViolationDelay = 0
    SharingViolationRetries = 0

    Autodisconnect = 4294967295 (0xffffffff)

    Also disabling the Details pane seemed to fix it on the client level.

  • Anonymous
    December 13, 2014
    The comment has been removed

  • Anonymous
    December 13, 2014
    I totally appreciated each and every little tad bit of it. I've bookmarked your web website to take a gander at out the new stuff you post.http://gold-and-silver-buyers.com/how-to-invest-in-gold-and-silver/

  • Anonymous
    December 13, 2014
    Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative.http://www.ddog.net">shock collar to stop barking

  • Anonymous
    December 13, 2014
    What a really awesome post this is. Truly, one of the best posts I've ever witnessed to see in my whole life. Wow, just keep it up.http://car-med.de/smart-lackier-karosserie.html

  • Anonymous
    December 13, 2014
    You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!!http://findyourdomainnow.com

  • Anonymous
    December 13, 2014
    I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.http://www.floorsandchores.net

  • Anonymous
    December 13, 2014
    You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming.http://followfy.com

  • Anonymous
    December 13, 2014
    I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.http://dripfollowers.com

  • Anonymous
    December 13, 2014
    I must say that I do believe this is the best content article. It offers every thing. I used this information to prove to my teacher that I was right and he was wrong. Thanks a lot for proving that!http://highstermobilereview.com

  • Anonymous
    December 13, 2014
    Great post. I am the regular targeted visitor of your site and also enjoy you making the effort to help keep your excellent site.http://howtolose-thighfat.org

  • Anonymous
    December 13, 2014
    Thanks for sharing the info, keep up the good work going.... I really enjoyed exploring your site. good resource...http://hotpapermoney.com

  • Anonymous
    December 13, 2014
    This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post!http://drracanelli.com

  • Anonymous
    December 16, 2014
    So weird, Step III. "Turn off the Preview Pane, Details Pane and pop ups that show information about file and desktop items" actually did it for me.

    Thanks Will!

  • Anonymous
    May 02, 2016
    The comment has been removed

  • Anonymous
    July 12, 2016
    Had this issue on a co-workers machine. Turned off the preview pane and viola! Simple as that.Yes I could have done the updated that addressed the issue, but this was a quicker fix and the user didn't want the preview stuff anyway.Thanks!

  • Anonymous
    August 01, 2016
    Hi therei have this issue with a Windows Server 2012 R2. nothing of the above mentioned helps at all. Any hints?

  • Anonymous
    August 28, 2016
    Halleluyah. SO grateful for this tip. Disabling the details and preview panes solved the problem for me too.

  • Anonymous
    October 05, 2016
    The origin of this problem is just a bad use.A file where many users write it must be set in excel as a shared/protected file.We have a lot of problem with our customers with file protected but not shared. By ourside we have files that are shared and we have no problem.It's just a PEBKAC but some times , there are bugs... Thoses bugs are created because of a bad use.It's what I'had could test and read around this problem.

  • Anonymous
    February 23, 2017
    thank for reply, actually, case is , we know that file is already opened at another user, we just don’t know the user name.(we can know name with help of server system administrator but everytime it is not possible to check with administrator, so we want excel to display user name.)As per , The Definitive 'Locked File' Post ,2 hotfixes are their, but both are for older version, Excel 2007 – http://support.microsoft.com/kb/2598133Excel 2010 – http://support.microsoft.com/kb/2598143we want for Office excel 2013.