How to rematch a geocoded feature class interactively


This VBA code demonstrates how to rematch a geocoded feature class interactively.
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

  1. Paste this code into VBA in ArcCatalog.
  2. In the ArcCatalog tree, select a geocoded feature class or shapefile.
  3. Run the RematchInteractively macro.
  4. Use the Interactive Rematch dialog to interactively rematch the geocoded feature class.
[VBA]
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






Additional Requirements
  • A geocoded shapefile or feature class.