View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default RangeFromPoint ... on a chartsheet ?

Insert some shapes on the chartsheet and try this in the Chart (sheet)
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" wrote in message
...
Hi,

The RangeFromPoint method cannot be used on a chartsheet 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 worksheet, but it will
generate a bug for a chart sheet:

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