MS Word 2010 image copy/paste bug - file handle not released RRS feed

  • Question

  • Hi,

    I seem to have encountered a bug in MS Word 2010 and I want to verify that it is indeed a bug and that I am not doing something wrong. To reproduce it:

    1) Start MS Word 2010 and create a new document

    2) Insert your favourite image into the document. Save it somewhere eg. Desktop/test.docx and close Word

    3) Restart MS Word and open Destop/test.docx

    4) Create a new document (Document1)

    5) Select all in Desktop/test.docx, copy, and paste into Document1.

    6) Close Desktop/test.docx

    7) Try to reopen Desktop/test.docx. Currently I am getting a 'test.docx is locked for editing by 'another user'' error.

    Inspection of the WINWORD.EXE process in Process Explorer shows that when test.docx is closed in step 6, it's file handle is not released, resulting in the locking problem.

    Further inspection of various temporary files created in the Content.MSO/ directory suggests that what is happening is: when you paste the embedded image file into the new document, and then close test.docx, the embedded image file remains preserved (perhaps by some sort of reference counted garbage collection algorithm?). As is it preserved, I am guessing that it's container document test.docx is also preserved.

    This doesn't seem right. Can anyone else reproduce the problem? If it is a bug where is the correct place to report it?

    Friday, June 17, 2011 3:33 AM

All replies

  • Hi,


    Thanks for point this out.

    We can repro the issue. However, this is not a bug. When you copy/cut a picture into Office clipboard, the clipboard will keep the reference to this picture until copying some new data into the clipboard. So in the scenario as you described, the clipboard keeps the reference to the picture even the document has closed (not the Word application closed). When the document reopen, Word detects that the document is already exist, which causes you receive the error message.

    If you want to have more effective understanding of how Office clipboard works, please have a look at this thread:


    For more information about "The document is locked for editing by another user"


    I hope this helps.

    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 23, 2011 12:18 PM
  • The problem because:


    This behavior may occur if Word determines that the owner file for the document already exists. This may occur if one or more of the following conditions are true:

    • Word previously quit improperly and, therefore, did not delete the owner file.

    • A second instance of Word is running in the background with the document already open.

    • The document is shared over a network, and another user has it open.

    The solution:


    To resolve this issue, first confirm that another user on the network does not have the document open. If the document is in use, open the document as read-only. If it is not in use, quit all instances of Word, and then remove the owner file. To do so, follow these steps.

    NOTE: Because there are several versions of Microsoft Windows, the following steps may be different on your computer. If they are, see your product documentation to complete these steps.
    1. Quit all instances of Word. To do so, follow these steps:
      1. Save all your work, and then quit all programs.
      2. Press CTRL+ALT+DELETE to open the Windows Security dialog box.
      3. Click Task Manager, and then click the Processes tab.
      4. Click Winword.exe, and then click End Process.
      5. In the Task Manager Warning dialog box, click Yes.

        If you receive a message that states that the program is not responding, clickEnd Now.
      6. Repeat steps d and e for each occurrence of Winword.exe.
      7. On the File menu, click Exit Task Manager.
    2. Start Windows Explorer, and then browse to the folder that contains the document file that you tried to open when you received the error message.
    3. Delete the owner file.

      The owner file is located in the same folder as the document that you tried to open. The owner file name uses the following convention: It begins with a tilde (~), followed by a dollar sign ($), followed by the remainder of the document file name. The file name extension is .doc. For example, the owner file for Document.doc is named ~$cument.doc.
    4. Start Word. If Word asks you whether you want to load the changes that were made to the Global or Normal template, click No.
    5. Open your document.
    Thursday, June 23, 2011 8:47 PM
  • Hi Calvin,

    Thanks for your reply.

    I don't think this behaviour is due to my misunderstanding of the Office clipboard. Please follow the steps I have posted, and clear the clipboard between steps 6) and 7). This does not solve the document locking problem.

    The real solution, I think, requires the link between the image in the clipboard and the containing document to be broken when the containing document is closed. This will allow the document file handle to be released. Word 2010 handles this fine for things like text and certain other OLE object, it just seems to have problems with images.

    Actually the reason we discovered this was that our software calls MS Word via the COM automation interface. The software composes a new document by copying from many different source documents, and pasting into the new one. It worked fine in Word 2007 but would choke on the 'User locked' problem in Word 2010, if a document containing an image was opened twice.

    I suspect that this isn't really correct behaviour for MS Word? Word 2007 certainly didn't do this. When a document is closed I would expect that the file handle should be released, allowing it to be reopened at any time. The fact that some of the document data remains in the clipboard should be irrelevant.


    Tuesday, June 28, 2011 7:53 AM
  • Thanks mnasr, however my problem is not due to any of the three cases mentioned on the MS support page. Killing Word and restarting it as Microsoft recommends will certainly fix the problem; however it's inelegant and more importantly, much too slow for our automation purposes.


    Tuesday, June 28, 2011 7:57 AM