+ Reply to Thread
Results 1 to 5 of 5

RangeFromPoint ... on a chartsheet ?

  1. #1
    MrT
    Guest

    RangeFromPoint ... on a chartsheet ?

    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


  2. #2
    Peter T
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >




  3. #3
    Peter T
    Guest

    Re: RangeFromPoint ... on a chartsheet ?

    When reading multiple objects from the selection at drawingobject level
    first time the first object that was selected is returned. Thereafter the
    order of objects is sorted into ZOrder's (order on sheet), the original
    selection order can no longer be read. If you put a loop in your code you'll
    see what I mean.

    For i = 1 To 2
    Set myobj = Selection(1)
    MsgBox myobj.Name, , myobj.ZOrder
    Set myobj = Selection(2)
    MsgBox myobj.Name, , myobj.ZOrder
    Next

    In the second loop items will returned in ZOrder

    Since XL97 MS suggest always use the Shape/ShapeRange level, although
    DrawingObjects and "Rectangle" etc has been maintained for backwards
    compatibility (and very useful too).

    Start afresh and try

    Set myobj = Selection.ShapeRange(1)
    MsgBox myobj.Name, , myobj.ZOrderPosition
    Set myobj = Selection.ShapeRange(2)
    MsgBox myobj.Name, , myobj.ZOrderPosition

    Items will be returned in ZOrderPosition regardless of the order they were
    selected. So if what you say is a bug, and in a sense it is confusing, it
    was fixed a long time ago.

    I'm curious, why do people keep posting these bug type suggestions in this
    manner before having thrashed it in the ng. Thereafter when people respond
    normally the OP doesn't reply.

    Regards,
    Peter T

    "MrT" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >




  4. #4
    Peter T
    Guest

    Re: RangeFromPoint ... on a chartsheet ?

    Oops - please ignore, it was intended for a different thread

    Peter T

    "Peter T" <peter_t@discussions> wrote in message
    news:[email protected]...
    > When reading multiple objects from the selection at drawingobject level..

    <snip>



  5. #5
    MrT
    Guest

    Re: RangeFromPoint ... on a chartsheet ?

    Peter,

    thanks for that. Very useful !!

    MrT

    "Peter T" wrote:

    > 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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
    > >

    >
    >
    >


+ 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