Microsoft KB Archive/832287

= Error Message: Word Cannot Save This File Because It Is Already Open Elsewhere =

Article ID: 832287

Article Last Modified on 7/27/2006

-

APPLIES TO


 * Microsoft Office Word 2003
 * Microsoft Word 2002 Standard Edition

-



SYMPTOMS
When you run a Microsoft Visual Basic for Applications (VBA) macro in Microsoft Word to open and then to save the changes to a Word document, you may receive the following error message:

Word cannot save this file because it is already open elsewhere.

(\\ \ \ .doc)

For example, this problem may occur when you run a VBA macro that is similar to the following example: Sub Test

Dim WordDoc As Word.Document

'Open the file (using UNC name) in Word Set WordDoc = Application.Documents.Open(&quot;\\server\share\filename.doc&quot;)

'Save Changes to the same file name (using UNC name) WordDoc.SaveAs &quot;\\server\share\filename.doc&quot;, wdFormatDocument

WordDoc.Close

End Sub



CAUSE
This problem may occur if you have a mapped drive to the same location that your VBA macro is trying to save changes to the document.



WORKAROUND
To work around this problem, use one of the following methods.

Method 1: Use the ActiveDocument.FullName Property
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this problem, use the ActiveDocument.Fullname property as in the following macro example: Sub Test

Dim WordDoc As Word.Document

'Open the file (using UNC name) in with word Set WordDoc = Application.Documents.Open(&quot;\\server\share\filename.doc&quot;) 'Save Changes to the same file name (using the mapped drive) ActiveDocument.SaveAs ActiveDocument.FullName WordDoc.Close

End Sub

Method 2: Disconnect Your Mapped Drive
To work around this problem, disconnect your mapped drive before you run your VBA macro. To disconnect your mapped drive, follow these steps:
 * 1) Right-click Start, and then click Explore.
 * 2) On the Tools menu, click Disconnect Network Drive.
 * 3) In the Disconnect Network Drives dialog box, select the mapped drive that you want to disconnect, and then click OK.

Keywords: kberrmsg kbprb KB832287

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.