Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
Macro Code to Check Whether a File Is Already Open
Article ID: 138621 - View products that this article applies to.
This article was previously published under Q138621
For a Microsoft Excel 2002 version of this article, see 291295
For a Microsoft Excel 2000 version of this article, see 213383
The following Microsoft Visual Basic for Applications procedure is an example of how to determine if another user has a file open. This type of macro is useful if you are using a file that is shared over a network where only one user at a time should open the file.
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.
Sample Visual Basic ProceduresThis example checks to see if Book2.xls in the root directory of drive C is already open. If the file is not already open, the macro will open it.
Article ID: 138621 - Last Review: August 17, 2005 - Revision: 2.1