This VBA code demonstrates how to rematch a geocoded feature class interactively.
[VBA]
To rematch a geocoded feature class, you must get the Locator that was attached to the feature class when it was created. You can then use the locator's AddressLocatorUI object to rematch the geocoded feature class automatically.
When rematching a geocoded feature class interactively, you can use a QueryFilter to specify which features to rematch.
How to use
- Paste this code into VBA in ArcCatalog.
- In the ArcCatalog tree, select a geocoded feature class or shapefile.
- Run the RematchInteractively macro.
- Use the Interactive Rematch dialog to interactively rematch the geocoded feature class.
Private Const MESSAGEBOX_TITLE = "Rematch Interactively Geocoding Developer Tip"
Public Sub RematchInteractively()
Dim pAddressUI As esriLocationUI.IAddressUI '+++ address UI for the locator
Dim pAttachedLocator As esriLocation.IAttachedLocator '+++ AttachedLocator for the selected dataset
Dim pGxApplication As esriCatalogUI.IGxApplication '+++ reference to the parent ArcCatalog application
Dim pGxDataset As esriCatalog.IGxDataset '+++ selected GxDataset
Dim pGxObject As esriCatalog.IGxObject '+++ selected GXObject
Dim pLocator As esriGeoDatabase.ILocator '+++ locator used to geocode the selected dataset
Dim pLocatorManager As esriLocation.ILocatorManager '+++ LocatorManager object
'+++ get a reference to the parent application
If Not (TypeOf ThisDocument.Parent Is esriCatalogUI.IGxApplication) Then
MsgBox "This macro can only be used in ArcCatalog.", vbCritical, MESSAGEBOX_TITLE
Exit Sub
End If
Set pGxApplication = ThisDocument.Parent
'+++ get a reference to the seleted geocoded feature class
Set pGxObject = pGxApplication.SelectedObject
If Not TypeOf pGxObject Is esriCatalog.IGxDataset Then
MsgBox "The selected item is not a geocoded feature class.", vbCritical, MESSAGEBOX_TITLE
Exit Sub
End If
Set pGxDataset = pGxObject
'+++ determine if the selected dataset is a geocoded feature class
Set pLocatorManager = New esriLocation.LocatorManager
If Not pLocatorManager.HasLocatorAttached(pGxDataset.DatasetName) Then
MsgBox "The selected item is not a geocoded feature class.", vbCritical, MESSAGEBOX_TITLE
Exit Sub
End If
'+++ get the attached locator from the dataset
Set pAttachedLocator = pLocatorManager.GetLocatorFromDataset(pGxDataset.Dataset)
Set pLocator = pAttachedLocator.Locator
'+++ rematch the feature class interactively
Set pAddressUI = pLocator.UserInterface
With pAttachedLocator
pAddressUI.InteractiveReview ThisDocument.Parent.hWnd, .InputTable, Nothing, .InputFieldNamesList, .InputJoinFieldName, .OutputTable, .OutputFieldNamesList, .OutputJoinFieldName, pLocator
End With
End Sub