When running VBA code within ArcMap or ArcCatalog that includes references to Network Analyst objects, you get the following error message when you attempt to run the code:
'Compile error: User-defined type not defined'
esriNetworkAnalyst.olb and esriNetworkAnalystUI.olb are not included in the VBA list of references.
Solution or Workaround
You need to include references to the Network Analyst OLB files.
- Within VBA, click on Tools > References to show the References dialog box.
- Check on the references 'ESRI Network Analyst Object Library' and 'ESRI NetworkAnalystUI Object Library'.
- Click OK to dismiss the dialog.
- Re-run the VBA code.