J
John
Hi there,
I'm getting stuck with Collections:
I'm trying to write a procedure to sort the active selection of shapes into
alphabetical order based on the shapes text (Prop.Name). The sorted list
has been passed to an array (colShps) and works fine if there are no shapes
with the same name (text). I've therefore tried to create a collection,
from the selection, so that when an instance is found (strFoundName) it can
be removed from the collection there by not moving the same shape twice.
The code below is falling over at the "colSelColShps.Remove strFoundName"
row with a Run time error '5': "Invalid procedure or arguement".
It's hot and humid and my head hurts. Can anyone help?
Best regards
John
For Each shp In sel
colSelColShps.Add shp
Debug.Print CStr(shp)
Next shp
For Each x In colShps
Debug.Print CStr(x)
For z = 1 To colSelColShps.Count
If x = colSelColShps.Item(z).Cells("Prop.Name").ResultStr("") Then
strFoundName = colSelColShps.Item(z)
If colSelColShps.Item(z).Master.Name = "Square" Then
colSelColShps.Item(z).Cells("PinX") = topPinX
newPositionY = lastShpTop -
((colSelColShps.Item(z).Cells("Height")) * 0.5)
colSelColShps.Item(z).Cells("PinY") = newPositionY
lastShpTop = newPositionY -
((colSelColShps.Item(z).Cells("Height")) * 0.5)
End If
End If
Next z
colSelColShps.Remove strFoundName
Next x
I'm getting stuck with Collections:
I'm trying to write a procedure to sort the active selection of shapes into
alphabetical order based on the shapes text (Prop.Name). The sorted list
has been passed to an array (colShps) and works fine if there are no shapes
with the same name (text). I've therefore tried to create a collection,
from the selection, so that when an instance is found (strFoundName) it can
be removed from the collection there by not moving the same shape twice.
The code below is falling over at the "colSelColShps.Remove strFoundName"
row with a Run time error '5': "Invalid procedure or arguement".
It's hot and humid and my head hurts. Can anyone help?
Best regards
John
For Each shp In sel
colSelColShps.Add shp
Debug.Print CStr(shp)
Next shp
For Each x In colShps
Debug.Print CStr(x)
For z = 1 To colSelColShps.Count
If x = colSelColShps.Item(z).Cells("Prop.Name").ResultStr("") Then
strFoundName = colSelColShps.Item(z)
If colSelColShps.Item(z).Master.Name = "Square" Then
colSelColShps.Item(z).Cells("PinX") = topPinX
newPositionY = lastShpTop -
((colSelColShps.Item(z).Cells("Height")) * 0.5)
colSelColShps.Item(z).Cells("PinY") = newPositionY
lastShpTop = newPositionY -
((colSelColShps.Item(z).Cells("Height")) * 0.5)
End If
End If
Next z
colSelColShps.Remove strFoundName
Next x