Error Message: Word Cannot Save This File Because It Is Already Open Elsewhere
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.
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("\\server\share\filename.doc") 'Save Changes to the same file name (using UNC name) WordDoc.SaveAs "\\server\share\filename.doc", wdFormatDocument WordDoc.CloseEnd Sub
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.
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("\\server\share\filename.doc") 'Save Changes to the same file name (using the mapped drive) ActiveDocument.SaveAs ActiveDocument.FullName WordDoc.CloseEnd 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:
- Right-click Start, and then click Explore.
- On the Tools menu, click Disconnect Network Drive.
- In the Disconnect Network Drives dialog box, select the mapped drive that you want to disconnect, and then click OK.
Article ID: 832287 - Last Review: 09/18/2011 11:07:00 - Revision: 4.0