Re: RangeFromPoint ... on a chartsheet ?

Tech-Archive recommends: Speed Up your PC by fixing your registry



Peter,

thanks for that. Very useful !!

MrT

"Peter T" wrote:

Insert some shapes on the chart*** and try this in the Chart (***)
module

Private Sub Chart_MouseMove(ByVal Button As Long, _
ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
Dim elemID As Long
Dim a As Long
Dim b As Long
Static sName As String
Static oldArg1 As Long

Me.GetChartElement x, y, elemID, a, b
If elemID = xlShape Then
If oldArg1 <> a Then
oldArg1 = a
sName = Me.Shapes(a).Name
'set a Shape object ref here perhaps
End If
Application.StatusBar = sName & " X:" & x & " Y:" & y

ElseIf oldArg1 Then
oldArg1 = 0
sName = ""
Application.StatusBar = False
End If

End Sub

The GetChartElement arguments are also returned in the Chart_Select event.

Note xy are chart window coordinates not screen,

Regards,
Peter T


"MrT" <MrT@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:46F595EE-855B-42EB-9509-FB9527895D03@xxxxxxxxxxxxxxxx
Hi,

The RangeFromPoint method cannot be used on a chart*** to get the Shape
below given coordinates.

For example, the following code with return the name of the rectangle, if
you draw a rectangle at the top-left corner of a work***, but it will
generate a bug for a chart ***:

Public Sub MyName()

Dim ObjShape As Object

Set ObjShape = ActiveWindow.RangeFromPoint(x:=200, y:=200)
If Not ObjShape Is Nothing Then
MsgBox ObjShape.Name
End If

End Sub

Is there something equivalent for chartsheets?

If not, it would be great that RangeFromPoint is available on Chartsheets.

Regards,

Mr T




.


Quantcast