実行時エラー 9 に直面しています: 下のコードの範囲外の下付き文字ですが、最初は正常に機能しました。しかし、後ですべてのモジュールを連携してアドインを作成すると、エラーが表示されます。
Sub SelectSimilarshapes()
Dim sh As Shape
Dim shapeCollection() As String
Set sh = ActiveWindow.Selection.ShapeRange(1)
ReDim Preserve shapeCollection(0)
shapeCollection(0) = sh.Name
Dim otherShape As Shape
Dim iShape As Integer
iShape = 1
For Each otherShape In ActiveWindow.View.Slide.Shapes
If otherShape.Type = sh.Type _
And otherShape.AutoShapeType = sh.AutoShapeType _
And otherShape.Type <> msoPlaceholder Then
If (otherShape.Name <> sh.Name) Then
ReDim Preserve shapeCollection(1 + iShape)
shapeCollection(iShape) = otherShape.Name
iShape = iShape + 1
End If
End If
Next otherShape
ActiveWindow.View.Slide.Shapes.Range(shapeCollection).Select
Select Case iShape
Case 1
MsgBox "Sorry, no shapes matching your search criteria were found"
Case Else
MsgBox "Shapes matching your search criteria were found and are selected"
End Select
NormalExit:
Exit Sub
err1:
MsgBox "You haven't selected any object"
Resume NormalExit:
End Sub