然后还需对数组排序...
辗转实现如下:
Private Sub CommandButton2_Click()
Dim myCrt As New Collection, Crt As ChartObject
On Error GoTo ErrorHandler
'在已选择的对象集合中循环
For Each ChtObj In Selection.ShapeRange
'判别ChtObj的类型
If ChtObj.Type = msoChart Then
'MsgBox ChtObj.Name
myCrt.Add ChtObj.Name
End If
Next ChtObj
ReDim myTabs(1 To myCrt.Count)
For i = 1 To myCrt.Count
myTabs(i) = myCrt(i)
'MsgBox myTabs(i)
Next i
myTabs1 = Array_Sort(myTabs, False)
For i = 1 To UBound(myTabs1)
'MsgBox myTabs1(i)
With ActiveSheet.ChartObjects(myTabs1(i))
.Width = ChtWidth
.Height = ChtHeight
.Top = TopPosition
.Left = LeftPosition
TopPosition = TopPosition + .Height + Interv
End With
Next i
Exit Sub
ErrorHandler:
'空的错误处理
End Sub
Function Array_Sort(ArrayList As Variant, L As Boolean) As Variant
Dim aCnt As Integer, bCnt As Integer
Dim tempStr As String
For aCnt = LBound(ArrayList) To UBound(ArrayList) - 1
For bCnt = aCnt + 1 To UBound(ArrayList)
If L Then
'StrComp(MyArray(I), X, tp) < 0
If StrComp(ArrayList(aCnt), ArrayList(bCnt), 1) < 0 Then
tempStr = ArrayList(bCnt)
ArrayList(bCnt) = ArrayList(aCnt)
ArrayList(aCnt) = tempStr
End If
Else
If StrComp(ArrayList(aCnt), ArrayList(bCnt), 1) > 0 Then
tempStr = ArrayList(bCnt)
ArrayList(bCnt) = ArrayList(aCnt)
ArrayList(aCnt) = tempStr
End If
End If
Next bCnt
Next aCnt
Array_Sort = ArrayList
End Function
[此贴子已经被作者于2005-2-20 13:20:40编辑过] |