HOW TO
Instructions provided describe how to open the new feature class or new shapefile dialog box programmatically using VBA code. The code can be executed with a button-click in ArcCatalog.
If the location is a folder, the script opens the New Shapefile dialog box.
If the location is a geodatabase or feature dataset, the script opens the New Feature Class dialog box.
Note:
If a UIButtonControl already exists with the name 'UIButtonControl1'. To change the name of the UIButtonControl, it is necessary to make the change to the UIButtonControl code portion below, accordingly, before the button can be used.
Code:
' Notes:
' open new shapefile or geodb feature class dialog depending on the selected item
' if a folder is selected, it will be the shapefile dialog
' if a geodatabase (sde or personal) or feature dataset is selected, it will be a geodb feature class dialog
Private Sub UIButtonControl1_Click()
Dim pGxApp As IGxApplication
Set pGxApp = Application
Dim pSelObj As IGxObject
Set pSelObj = pGxApp.SelectedObject
' Debug.Print pSelObj.Category
Dim location As String
location = pSelObj.FullName
' Debug.Print location
Dim pCmdItem As ICommandItem
If pSelObj.Category = "Personal Geodatabase" _
Or pSelObj.Category = "Personal Geodatabase Feature Dataset" _
Or pSelObj.Category = "Spatial Database Connection" _
Or pSelObj.Category = "SDE Feature Dataset" Then
Set pCmdItem = Application.Document.CommandBars.Find(ArcID.Gx_NewFeatureClassMenu)
pCmdItem.Execute
ElseIf pSelObj.Category = "Folder" Or _
pSelObj.Category = "Folder Connection" Then
Set pCmdItem = Application.Document.CommandBars.Find(ArcID.Gx_NewShapefileMenu)
pCmdItem.Execute
Else
Exit Sub
End If
End Sub
Article ID:000008647
Get help from ArcGIS experts
Download the Esri Support App