'ArcCatalogでフォルダ内のフィーチャクラスを再帰検索 Public Sub GetFeatureClasses() Dim pGxApplication As IGxApplication Dim pGxObject As IGxObject Set pGxApplication = Application Set pGxObject = pGxApplication.SelectedObject If TypeOf pGxObject Is IGxFolder Then Dim pGxObjectContainer As IGxObjectContainer Set pGxObjectContainer = pGxObject Dim pEnumGxObject As IEnumGxObject Set pEnumGxObject = pGxObjectContainer.Children GetFeatureClass pEnumGxObject Else MsgBox "カタログ ツリーでフォルダを選択してください。", vbInformation End If End Sub '再帰関数 Private Function GetFeatureClass(EnumGxObject As IEnumGxObject) EnumGxObject.Reset Dim pGxObject As IGxObject Set pGxObject = EnumGxObject.Next Do Until pGxObject Is Nothing If TypeOf pGxObject Is IGxObjectContainer Then Dim pGxObjectContainer As IGxObjectContainer Set pGxObjectContainer = pGxObject If Not pGxObjectContainer.Children Is Nothing Then GetFeatureClass pGxObjectContainer.Children '再帰 End If End If If TypeOf pGxObject Is IGxDataset Then Dim pGxDataset As IGxDataset Set pGxDataset = pGxObject If pGxDataset.Type = esriDTFeatureClass Then Call RunTheFunction(pGxObject) End If End If Set pGxObject = EnumGxObject.Next Loop End Function Private Function RunTheFunction(GxDataset As IGxDataset) Debug.Print GxDataset.Dataset.Name End Function
ArcCatalog でフォルダー内のフィーチャクラスを再帰検索
2016/9/1 (木)