XL: Hiding Chart Toolbar with an XLM Macro Fails

ID: Q99519


The information in this article applies to:


SYMPTOMS

In the versions of Microsoft Excel listed above, if you create or activate a chart and then attempt to hide the chart toolbar in the same macro, the command to hide the toolbar may be applied to the worksheet window rather than the chart window. This results in the toolbar continuing to be displayed while the chart window is active. If you set the chart toolbar so that it would be displayed in a worksheet window, it will now be hidden.


WORKAROUND

Whenever a chart window is opened or activated in Microsoft Excel, the chart toolbar is automatically displayed by default. To change this default, you must disable the chart toolbar while a chart window is active. Once this is done, when you open or activate a chart, the toolbar will no longer be displayed.

If you have not changed this default and you run the following macro to create a chart and hide the chart toolbar


   Create_Chart
   =NEW("Chart")
   =SHOW.TOOLBAR(4,FALSE)
   =RETURN() 


the chart toolbar will continue to be displayed with the chart window active and will be designated as hidden for the worksheet window.

The macro that creates the chart needs to return before the SHOW.TOOLBAR(4,FALSE) command is executed. You can accomplish this by using the ON.TIME() function. ON.TIME() runs a designated macro at a specified time. It begins tracking the time when the macro return is reached and Microsoft Excel is in Ready mode. In the following macro sequence, the Hide_Toolbar macro will run 1 second after the Create_Chart macro returns:


   Create_Chart
   =NEW("Chart")
   =ON.TIME(NOW()+"00:00:01","Hide_Toolbar")
   =RETURN()

   Hide_Toolbar
   =SHOW.TOOLBAR(4,FALSE)
   =RETURN() 


STATUS

This is by design of the versions of Microsoft Excel listed at the beginning of this article.


MORE INFORMATION

When you run a macro, some of the functions in Microsoft Excel are not completed until after a specified wait state. In the example above, Microsoft Excel will not recognize that the toolbar is open until the macro that creates or activates the chart window is returned.


REFERENCES

"Function Reference," pages 285-286, 305-306, 398

Additional query words: 4.00a XL4 XL5


Keywords          : 
Version           : WINDOWS:4.0,4.0a,5.0; MACINTOSH:4.0,5.0
Platform          : MACINTOSH WINDOWS 
Issue type        : kbprb 

Last Reviewed: April 5, 1999