3

We're getting this a lot lately.

  • Windows 2008 Server
  • Windows 7 & Vista Client PC's
  • Microsoft Office 2007

When a user tries opening a file on our network drive (word doc, excel spreadsheet, etc) the software reports the file is locked by 'another user' even when it's not. They're also seeing random 'Sharing Violation' errors when trying to save files to the network.

Possibly the same manifestation of the problem shows up when a user tries saving a local, on their own drive, non-network files and they get 'Can not save due to a Sharing Violation'.

7 Answers 7

9

OK, after tracking down potential problems and testing solutions since this question was posted I have the answer...

Anything that accesses files in real time (antivirus, syncing, or indexing software) can potentially create problems with Microsoft Office files.

Microsoft Office creates temp (with and without a file extensions) files when saving. Overzealous realtime scanning programs sometimes see these temp files, try and read their contents, and in doing so initiate file locks. This causes instant problems when the parent application tries to convert the temp file back to its intended format.

From MSKB: Description of the way that Excel saves files

When Excel saves a file, Excel follow these steps:

  1. Excel creates a randomly named temporary file (for example, Cedd4100 with no file name extension) in the destination folder that you specified in the Save As dialog box. The whole workbook is written to the temporary file.
  2. If changes are being saved to an existing file, Excel deletes the original file.
  3. Excel renames the temporary file. Excel gives the temporary file the file name that you specified (such as Book1.xls) in the Save As dialog box.

From MSKB: Description of how Word creates temporary files

A simplified view of the scheme used to save an edited file

Create temp file
Write temp file
Delete original file
Move temp to target name

Word gains significant performance speed by placing the temporary file in the same directory as the saved file. If Word placed the temporary file elsewhere, it would have to use the MS-DOS COPY command to move the temporary file from the other directory to the saved location. By leaving the temporary file in the same directory as the saved document file, Word can use the MS-DOS MOVE command to quickly designate the temporary file as the saved document.


Most av, indexing, and syncing software handle the temp files correctly; some don't. And some work fine on their own but not well together when watching the same folder. It's up to you to figure out what program is causing the issue in your environment. Hopefully this answer gives a guiding light in the right direction.

Update: Microsoft has released a couple hotfixes to address this issue.
Office 2007 Hotfix
Excel 2007 Hotfix
Instead of requesting the hotfixes from MS, search for them at The Hotfix Share.

FYI: Neither completely solves our problem but they do significantly reduce "sharing violation" frequency.

2

Something that I've noticed using Windows Vista is that it does 'lock' files at random.

I use Unlocker to show me where it is locked and it allows me to unlock the file.

3
1

Is it possible that other users are somehow disconnecting from the share without closing the application first? i.e. laptop users that simply close the lid for Standby and go home? Perhaps other network connectivity issues?

I'd look in the shared drive for lock files - they usually start with a tilde. For example, document.docx would have a lock file in the same directory that would be ~$document.docx. This is a hidden file, so you need to enable Show Hidden Files And Folders in Explorer to see it.

If the application sees this file, regardless of the permissions actually granted, it will tell you the file is locked because it didn't generate that lock file. If an application didn't close correctly, or was forcibly disconnected by going into standby or being unplugged from the network, it won't properly remove that lock file.

Just a thought...

Jes

1

Turn off the Details Pane shown at the bottom of Windows Explorer. Go to Organize -> Layout -> Details Pane. That fixes the first problem.

Turn off Show pop-up description for folder and desktop items 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, clear the checkbox and then click OK. This fixes the second problem.

Turn off Preview Pane. Go to Organize -> Layout -> Preview Pane. This fixes number 3.

1
  • It's actually far easier and far more effective to simply enable "classic" mode. Oct 21, 2012 at 0:26
0

The error indicates that the other user has locked the file when this user tried to open it. The read/write access controls for this user have no significance when the lock is present.

Possible reasons,

  • Is the file being stored in locations that are shared with write access?
  • Did the previous access of the file terminate with an application crash?

MS Office applications usually open files in write mode. If someone has it opened, or if the application crashed the last time with this file open, you are likely to get this error.

Another small observation: have you noticed, a doc/xls file that is open but not yet edited actually has its timestamp modified to when it was opened (if you switch to explorer and see its listing). This is restored to the older timestamp if you close the file without any edits/save. This is because the file is opened in write mode.

0

Check too that they have the ability to create files in that folder. The program tells if it is allowed to write by the pressence of a ~$document.docx (or whatever) that it holds. If it can not create that file or another program has the handle to it it then assumes it is read only.

0

Microsoft Office applications gets the username from the field in options under the general tab of excel, user information tab in word etc.

check the clients to see what the field has in it in the tab.....

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .