Excel: Macro Error when Adjusting an Embedded Chart

Last reviewed: September 2, 1997
Article ID: Q78917

The information in this article applies to:
  • Microsoft Excel for Windows, version 3.0, 4.0
  • Microsoft Excel for OS/2, version 3.0

SUMMARY

If you are attempting to make modifications to an embedded chart in Microsoft Excel from within a macro, the macro may halt with an error message if you have previously edited the chart. The problem occurs if you have not closed or hidden the chart window after making the previous modifications.

MORE INFORMATION

To modify an embedded chart from within a macro, you must first execute the UNHIDE function on the chart to display the editable chart window. To then return to the embedded chart, you should either close or hide the separate chart window. This makes it possible to unhide and make further changes to the chart the next time the macro is called.

The following macro would convert an embedded chart (of any type) to a line chart:

   =UNHIDE("Sheet1 Chart 1")
   =GALLERY.LINE(3,TRUE)
   =ACTIVATE("Sheet1")
   =RETURN()

This macro does not close the chart window that was activated with the UNHIDE function. It simply brings the original worksheet to the foreground so that the chart window is no longer visible. Subsequent attempts to execute the UNHIDE function, as shown above, result in a macro error because the chart is not a hidden window.

To modify the chart a second time after running the macro shown above, issue the command =ACTIVATE("Sheet1 Chart 1"), or modify the macro shown above by replacing the =ACTIVATE("Sheet1") with either =HIDE() or =CLOSE(). Either method works equally well.

REFERENCES

"Microsoft Excel Function Reference," version 3.0, page 241

"Microsoft Excel User's Guide," version 3.0, pages 391-394


Additional query words: 3.00 4.00 4.0
Keywords : PgmHowTo PgmOthr


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 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.