Microsoft KB Archive/211856

= XL2000: Referenced Workbooks and Add-Ins Are Automatically Opened =

Article ID: 211856

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q211856





SUMMARY
In Microsoft Excel 2000, when you create a reference from a workbook to another workbook or to an add-in, the referenced workbook or add-in is automatically opened. This is different from behavior in versions of Microsoft Excel prior to Excel 97. In versions prior to Excel 97, the referenced workbook or add-in is not automatically opened.

This article explains the problems that you may encounter when you reference other workbooks and add-ins in Microsoft Excel 2000.



MORE INFORMATION
To create a reference from one workbook to another workbook or to an add-in, follow these steps:
 * 1) Switch to the workbook from which you want to create the reference.
 * 2) On the Tools menu, point to Macro, and then click Visual Basic Editor.
 * 3) On the Tools menu, click References.
 * 4) In the References-VBAProject dialog box, click to select the check box to the left of the file for which you want to create the reference. If the file is not listed, click Browse, select the file in the Add Reference dialog box, and then click Open.
 * 5) Click OK.

A workbook that contains a reference to another workbook or to an add-in is a "referencing" workbook. A workbook or add-in that is referred to by another workbook is a "referenced" workbook.

Errors Opening Referenced Workbooks or Add-Ins with Visual Basic Macros
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

If you attempt to use a Visual Basic for Applications macro to open a workbook or add-in that is already referenced by another open workbook, you may receive the following error message:

Run-time error '1004': This workbook is currently referenced by another workbook and cannot be closed.

For example, if Book1.xls references Book2.xls, you receive the error message if a Visual Basic macro executes the following line of code: Workbooks.Open FileName:="Book2.xls" To prevent the error message from appearing, modify the Visual Basic code to the following: On Error Resume Next                  ' Prevents the error message. Workbooks.Open FileName:="Book2.xls"  ' Opens the workbook or add-in. On Error GoTo 0                       ' Restores normal error handling.

Errors Closing Referenced Workbooks or Add-ins
In Microsoft Excel 2000, you cannot close a referenced workbook or add-in if the referencing workbook is open. If you attempt to do so, you receive one of the following error messages:

This workbook is currently referenced by another workbook and cannot be closed.

-or-

Run-time error '1004': This workbook is currently referenced by another workbook and cannot be closed.

For additional information this problem, click the article number below to view the article in the Microsoft Knowledge Base:

213547 XL2000: Cannot Programmatically Close Referenced Workbook

Errors When Multiple Users Reference the Same Workbook or Add-In
Because Microsoft Excel 2000 automatically opens referenced workbooks and add-ins, you may experience problems if multiple users reference the same copy of a workbook or an add-in. This problem may occur if you create a reference to a workbook or to an add-in stored on a network server, or if you open a workbook that contains this kind of reference.

The first user who creates the reference does not receive an error message. However, all users who subsequently create a reference or open a workbook that contains this kind of reference may receive the following error message:

' ' is being modified by. Open as Read-Only, or choose Notify to be alerted when it is available.

If you click Cancel in the File Reservation dialog box, you may also receive the following error message:

Can't add a reference to the specified file.

If you use a Visual Basic macro to open the referencing workbook, the previous error message may not appear immediately, and the workbook is opened without any problems. When the error message does appear, click Read-Only or Notify.

If multiple users share the same copy of an add-in, you may want to give each user a copy of the add-in, and then ask each user to change the reference to refer to his or her respective copy of the add-in. By doing this, you can prevent this problem from occurring.

Additional query words: XL2000

Keywords: kbhowto kbprogramming KB211856

-

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

© Microsoft Corporation. All rights reserved.