|    | 
     ▼sakumambo さん: 
>▼kanabun さん: 
>コネクタがつながっていないオートシェイプを探したいです。 
>コネクタがつながっていないオートシェイプが存在するのは作図ミスなのでそれを発見しなければならないといことで、困っています。 
>用途を書かずすみませんでした。 
 
そうすると、最初に Dictionaryに図形名を全部登録しておいて、 
それから先ほどの「コネクターが接続している図形」名を調べ、その 
名前がDictionaryにあれば削除していき、 ... Dictionaryに残った図形 
名が、コネクタが接続されていない、ということかな? 
 
Sub コネクタが接続されていないAutoShape() 
 Dim shp As Object 
 Dim dic As Object 
 Dim ss As String 
  
 Set dic = CreateObject("Scripting.Dictionary") 
 'すべての図形名を辞書に登録 
 For Each shp In ActiveSheet.DrawingObjects 
   dic(shp.Name) = Empty 
 Next 
 'コネクタにつながっている図形を除外 
 For Each shp In ActiveSheet.DrawingObjects 
   With shp.ShapeRange 
    If .Connector Then 'コネクターだったら 
     With .ConnectorFormat 
       If .BeginConnected Then 
         ss = .BeginConnectedShape.Name 
         If dic.Exists(ss) Then dic.Remove ss 
       End If 
       If .EndConnected Then 
         ss = .EndConnectedShape.Name 
         If dic.Exists(ss) Then dic.Remove ss 
       End If 
     End With 
    End If 
   End With 
 Next 
  
 If dic.Count > 0 Then 
   MsgBox Join(dic.Keys(), vbCrLf), , _ 
       "Connectorにつながっていない図形は" 
 Else 
   MsgBox "すべての図形はConnectorと接続中" 
 End If 
End Sub 
 | 
     
    
   |