+ Reply to Thread
Results 1 to 3 of 3

ActiveChart.Deselect won't Deselect

  1. #1
    Mark Stephens
    Guest

    ActiveChart.Deselect won't Deselect

    The code below works beautifully except for the Deselection of the chart
    which steadfastly refuses to work. I even added

    ActiveChart.ChartArea.Select

    as an intermediate step to encourage it and two more chances before it
    exits! What can be the problem here? The code is obviously executing but for
    some reason does not see itself as active as soon as the event is triggered.

    ANhyone know why it won't Deselect?

    Thanks for your help, Mark


    Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal
    x As Long, ByVal y As Long)

    Dim ElementID As Long, Arg1 As Long, Arg2 As Long


    With ActiveChart

    ' Pass x & y, return ElementID and Args
    ..GetChartElement x, y, ElementID, Arg1, Arg2

    ' Did we click on a point?
    If ElementID = xlSeries Then

    'Is it already Exploded?
    If ActiveChart.SeriesCollection(1).Points(Arg2).Explosion > 0
    Then
    ActiveChart.SeriesCollection(1).Points(Arg2).Explosion = 0
    ActiveChart.ChartArea.Select
    ActiveChart.Deselect
    Else
    ActiveChart.SeriesCollection(1).Points(Arg2).Explosion = 20
    ActiveChart.ChartArea.Select
    ActiveChart.Deselect
    End If

    End If

    ActiveChart.ChartArea.Select
    ActiveChart.Deselect

    End With

    ActiveChart.ChartArea.Select
    ActiveChart.Deselect


    End Sub



  2. #2
    Tushar Mehta
    Guest

    Re: ActiveChart.Deselect won't Deselect

    My guess would be it is because the user has the mouse button down and
    XL is 'reluctant' to deselect something the user has just selected?

    If Activechart.Deselect is in a sub by itself and that sub is run with a
    chart selected, XL correctly deselects the chart.

    As a side note...Interestingly, I had always thought some object in XL
    had to be selected at all times. However, after executing the .Deselect
    line, if one checks in Immediate window, one finds that there is an
    activesheet and an activechart. However, selection is nothing!

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Multi-disciplinary business expertise
    + Technology skills
    = Optimal solution to your business problem
    Recipient Microsoft MVP award 2000-2005

    In article <[email protected]>, [email protected] says...
    > The code below works beautifully except for the Deselection of the chart
    > which steadfastly refuses to work. I even added
    >
    > ActiveChart.ChartArea.Select
    >
    > as an intermediate step to encourage it and two more chances before it
    > exits! What can be the problem here? The code is obviously executing but for
    > some reason does not see itself as active as soon as the event is triggered.
    >
    > ANhyone know why it won't Deselect?
    >
    > Thanks for your help, Mark
    >
    >
    > Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal
    > x As Long, ByVal y As Long)
    >
    > Dim ElementID As Long, Arg1 As Long, Arg2 As Long
    >
    >
    > With ActiveChart
    >
    > ' Pass x & y, return ElementID and Args
    > .GetChartElement x, y, ElementID, Arg1, Arg2
    >
    > ' Did we click on a point?
    > If ElementID = xlSeries Then
    >
    > 'Is it already Exploded?
    > If ActiveChart.SeriesCollection(1).Points(Arg2).Explosion > 0
    > Then
    > ActiveChart.SeriesCollection(1).Points(Arg2).Explosion = 0
    > ActiveChart.ChartArea.Select
    > ActiveChart.Deselect
    > Else
    > ActiveChart.SeriesCollection(1).Points(Arg2).Explosion = 20
    > ActiveChart.ChartArea.Select
    > ActiveChart.Deselect
    > End If
    >
    > End If
    >
    > ActiveChart.ChartArea.Select
    > ActiveChart.Deselect
    >
    > End With
    >
    > ActiveChart.ChartArea.Select
    > ActiveChart.Deselect
    >


  3. #3
    Jon Peltier
    Guest

    Re: ActiveChart.Deselect won't Deselect

    I recorded a macro while selecting and deselecting a chart, then
    selectively removed lines until it almost worked, then added one more line.

    These are the two lines you need:

    Windows(ActiveWorkbook.Name).Activate
    ActiveCell.Select

    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com/
    _______


    Mark Stephens wrote:

    > The code below works beautifully except for the Deselection of the chart
    > which steadfastly refuses to work. I even added
    >
    > ActiveChart.ChartArea.Select
    >
    > as an intermediate step to encourage it and two more chances before it
    > exits! What can be the problem here? The code is obviously executing but for
    > some reason does not see itself as active as soon as the event is triggered.
    >
    > ANhyone know why it won't Deselect?
    >
    > Thanks for your help, Mark
    >
    >
    > Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal
    > x As Long, ByVal y As Long)
    >
    > Dim ElementID As Long, Arg1 As Long, Arg2 As Long
    >
    >
    > With ActiveChart
    >
    > ' Pass x & y, return ElementID and Args
    > .GetChartElement x, y, ElementID, Arg1, Arg2
    >
    > ' Did we click on a point?
    > If ElementID = xlSeries Then
    >
    > 'Is it already Exploded?
    > If ActiveChart.SeriesCollection(1).Points(Arg2).Explosion > 0
    > Then
    > ActiveChart.SeriesCollection(1).Points(Arg2).Explosion = 0
    > ActiveChart.ChartArea.Select
    > ActiveChart.Deselect
    > Else
    > ActiveChart.SeriesCollection(1).Points(Arg2).Explosion = 20
    > ActiveChart.ChartArea.Select
    > ActiveChart.Deselect
    > End If
    >
    > End If
    >
    > ActiveChart.ChartArea.Select
    > ActiveChart.Deselect
    >
    > End With
    >
    > ActiveChart.ChartArea.Select
    > ActiveChart.Deselect
    >
    >
    > End Sub
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1