Sandy -
Are you messing with the visible property of the chart command bar? If
not, even if it appears and disappears during the macro, it will retain
its behavior.
The chart command bar wants to stay invisible when no chart is active,
and visible when a chart is active. If you set the visible property to a
state it doesn't like, it will stay in that condition whether or not a
chart is selected. If the visible property is already in a state it
doesn't like, changing the setting will revert it to its happy changing
state. There seems to be a third setting besides True and False for the
..Visible property: Maybe. (xlMaybe? xlWhatever.)
Since that doesn't seem very clear, I'll give an example. If the chart
is visible and so is the chart menu, making the chart menu invisible
will mean it stays hidden no matter what you select. If you select the
chart, then make the chart command bar visible, it reverts to the
witching behavior. If you then unselect the chart, the chart command bar
goes away. Make it visible now and it will stay visible.
All of the command bars that pop in and out based on the selection
function in the same manner.
But the best you can do is not change the setting at all.
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
Sandy V wrote:
> Hi Tushar,
>
> First of all thanks for replying.
>
> The trouble is the chart menu visible property can change
> from true / false simply by selecting / deselecting a
> chart (depending on user settings). And this may occur
> while my code is running. I can only return the visible
> property at any one time. So the problem is how to detect
> the original combination of settings, and eventually re-
> apply same.
>
> I think settings could be any of these combinations
>
> No Chart selected | Chart selected
> False | False
> False | True
> True | True
> but not
> True | False
>
> Consider this scenario:
> Original setup is False | True
> Chart selected, code starts, menu visible so
> SavedState = True
> Chart deselected, menu not visible
> Code about to terminate, apply SavedState (true)
>
> But this is not correct, if no chart is selected the
> correct setting for the menu should be visible = False
>
> One solution would be to select / deselect a chart at an
> early stage of code and detect the combination, then do
> similar when done. But I prefer not to do this.
>
> I could be missing something simple, hope I am!
>
> Regards,
> Sandy
>
>
>>-----Original Message-----
>>OK, so what am I missing? Why not use a variable for the
>>current value, change it as desired and restore the
>>setting from the variable used to store the current
>>setting? You already know the correct syntax for the
>>property. To get you started, consider the untested
>>
>>Dim SavedState as Boolean
>>SavedState=Application.CommandBars("Chart").Visible
>>....
>>
>>--
>>Regards,
>>
>>Tushar Mehta
>>www.tushar-mehta.com
>>Multi-disciplinary business expertise
>> + Technology skills
>> = Optimal solution to your business problem
>>Recipient Microsoft MVP award 2000-2004
>>
>>In article <c7e301c438e6$642311f0$(E-Mail Removed)>,
>>(E-Mail Removed) says...
>>
>>>Hi,
>>>
>>>On a worksheet there appear to be two independent
>
> settings
>
>>>for -
>>>Application.CommandBars("Chart").Visible
>>>
>>>One when no chart is selected, and another when a chart
>
> is
>
>>>active. Typically they would be False and True
>>>respectively.
>>>
>>>I would like to return, apply my own settings, then
>>>correctly restore both when done, regardless as to
>
> whether
>
>>>or not a chart is selected, and without having to
>
> select /
>
>>>de-select a chart.
>>>
>>>TIA,
>>>Sandy
>>>
>>
>>.
>>