Microsoft Knowledge Base |
|
XL: Macro Error Referencing Window in Version 4.0 Workbook |
|
|
Last reviewed: March 27, 1997
Article ID: Q115904 |
|
|
5.00 5.00c 7.00 7.00a | 5.00 5.00a
WINDOWS | MACINTOSH
kbusage
The information in this article applies to:
SYMPTOMSIn the versions of Microsoft Excel mentioned above, if you open a Microsoft Excel version 4.0 workbook file, and run a macro contained in the workbook file that references the workbook name, you receive a macro error message.
CAUSEYou receive this error message when a command in the Microsoft Excel version 4.0 macro references a sheet in the workbook, or the workbook itself is using the workbook name listed on the Window menu. In the versions of Microsoft Excel mentioned above, when you open a Microsoft Excel version 4.0 workbook file that was saved while the bound sheets were open, a separate window is opened for each sheet in the workbook. The workbook name appears on the Window menu for each open sheet, with the workbook name followed by a colon and a number indicating the window number. For example, when you open the Microsoft Excel version 4.0 workbook file, BOOK1.XLS that contains the sheets SHEET1.XLS and SHEET2.XLS, the Window menu displays BOOK1.XLS:1 (with SHEET1.XLS as the active sheet), and BOOK1.XLS:2 (with SHEET2.XLS as the active sheet). If your macro uses the workbook name listed on the Window menu, for example, if you use the UNHIDE macro formula to open an embedded chart in a workbook, and use the WINDOWS macro function to get the workbook name, the macro error occurs because of the number following the workbook name.
WORKAROUNDTo avoid receiving a macro error when you run a macro that references the name of a Microsoft Excel version 4.0 workbook from the Window menu, do either of the following:
A1: =SET.NAME("WinName",INDEX(WINDOWS(),1))
A2: =IF(NOT(ISERR(FIND(":",WinName))))
A3: =SET.NAME("WinName",MID(WinName,1,LEN(WinName)-2))
A4: =END.IF()
A5: =UNHIDE(WinName & " Chart 1")
A6: =RETURN()
|
|
KBCategory: kbusage
©1997 Microsoft Corporation. All rights reserved. Legal Notices. |