Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default This is wierd!

Greetings

I am using Excel 2003 - I don't know how this would work in other
versions.

Open up a new workbook and put 2 shapes (I used ovals) on the sheet.
Then group them. In a code module add:

Sub disappointing()
Dim myName As String
Dim shp As Shape
myName = Sheets(1).Shapes("Group 3").GroupItems(1).name
MsgBox myName
Set shp = Sheets(1).Shapes("Group 3").GroupItems(myName)
MsgBox shp.name
End Sub

The first msgbox gives "Oval 1" as expected but the next line throws a
run-time "subscript out of range" error. GroupItems is expecting an
integer and can't handle a string like a full-fledged collection (such
as Shapes itself) could do - disappointing design if you ask me.

*But*

I you now enter:

Sub wierd()
Dim shp As Shape
For Each shp In Sheets(1).Shapes("Group 3").GroupItems
shp.Select
Selection.name = shp.name
Next shp
End Sub

And run it and *then* run disappointing () - you discover that the
subscript error has vanished and that both msgboxes work as hoped. What
is going on here? It seems that going through Selection is needed - it
somehow makes the shape names magic or something so that they cause
GroupItems, against all documentation, to start acting like a
collection.

-semiopen

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd Data sorting Cathy b. Excel Worksheet Functions 1 October 14th 08 07:48 PM
Totally wierd Fritz Excel Worksheet Functions 4 July 23rd 07 01:44 PM
Wierd VBA happenings... LT Excel Discussion (Misc queries) 4 March 15th 07 02:10 PM
Wierd event Freddie Excel Discussion (Misc queries) 0 March 17th 06 02:49 PM
Wierd XL Behavior revwhop Excel Discussion (Misc queries) 1 March 13th 06 02:34 PM


All times are GMT +1. The time now is 01:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"