XL5: Methods Fail When Embedded Chart Is Edited

Last reviewed: September 12, 1996
Article ID: Q111971
The information in this article applies to:

- Microsoft Excel for Windows, version 5.0

SUMMARY

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)

STATUS

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.

MORE INFORMATION

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.

WORKAROUND

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



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.