View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default xl2000 vs. xl2003 RangeFromPoint and Grouped Shape


Greg,
That is pretty clever coding and I think I may be able to find a use for it.
See if this is close to what you need, it worked on one group...
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

'--
Sub xyz()
Dim obj As Object
Dim shp As Shape
Dim cpos As POINTAPI
With ActiveWindow
Do
GetCursorPos cpos
Set obj = .RangeFromPoint(cpos.x, cpos.y)
Range("A1").Value = TypeName(obj)
Select Case TypeName(obj)
Case "Range", "Nothing"
With Range("A2")
If .Value < "" Then Range("A2:A3").ClearContents
End With
Case Else
Range("A2").Value = obj.Name
On Error Resume Next
Set shp = ActiveSheet.Shapes(obj.Name)
If Err.Number = 0 Then
Range("A3").Value = GroupShapesName(shp.Name)
End If
On Error GoTo 0
End Select
DoEvents
Loop Until cpos.x = 0 Or cpos.y = 0
End With
Set obj = Nothing
End Sub
'--

Function GroupShapesName(ByRef strName As String) As String
Dim shp As Shape
Dim x As Long
Dim N As Long

For Each shp In ActiveSheet.Shapes
If shp.Type = msoGroup Then
x = shp.GroupItems.Count
For N = 1 To x
If shp.GroupItems(N).Name = strName Then
GroupShapesName = shp.Name
Exit Function
End If
Next
End If
Next
Set shp = Nothing
End Function
'--




"Greg Wilson"
wrote in message
Sorry for getting back so late. I had to go to work for a few hours in the
middle of the night.

-snip-
QUESTION:
In xl2000, how can I efficiently determine what grouped shape is under the
mouse pointer using RangeFromPoint ?
Very appreciative of your time.
Greg