ID: Q111971
5.00 WINDOWS buglist5.00 fixlist5.00c
The information in this article applies to:
- Microsoft Excel for Windows, version 5.0
In Microsoft Excel version 5.0, the following methods may fail if the active sheet is an embedded chart that is currently being edited and if an object is not specified for the method:
- Charts Method (Syntax 2) - DialogSheets Method (Syntax 2) - Modules Method (Syntax 2) - Sheets Method (Syntax 2) - Worksheets Method (Syntax 2)
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.
Each of the above methods is used to return a collection of a particular type of sheet. For example, the Sheets method (Syntax 2) returns a collection that consists of all of the sheets in a workbook.
If you do not include an object for each of the above methods, the object "ActiveWorkbook" is assumed for the method. For example, these two commands are equivalent:
ActiveWorkbook.Sheets.Count
Sheets.Count
Because the ActiveWorkbook object is assumed for the second command,
both commands return the number of sheets in the active workbook.
However, if an embedded chart is currently being edited (that is, it is surrounded by a hatched diagonal border, or it is in its own window), the above methods may fail if an object is not explicitly included. For example, if an embedded chart is currently being edited and you use the command
Sheets.Count
you will receive the error message:
Run-time error '1004':
Sheets method of Application class failed
However, "ActiveWorkbook.Sheets.Count" will work properly even if an
embedded chart is being edited. Explicitly including an object for
each of the various methods will prevent the error from occurring.
To prevent this type of error from occurring, include a specific object with the method. For example, instead of
Sheets.Count
use:
ActiveWorkbook.Sheets.Count
-or-
Workbooks("WORKBOOK.XLS").Sheets.Count
Either of these workarounds will keep the error described above from
occurring.
KBCategory: kbprb KBSubcategory:
Additional reference words: 5.00
Version : 5.00
Platform : WINDOWS
Last Reviewed: September 14, 1996