How to find nearest point on a line to a point in a different feature class with VBA?

Discussion created by erdhummel on May 9, 2010

for several buildings I have determined the central point of the building edges and saved those in a point feature class. Marked by red dots in the graphic. There are also road axes in the graphic marked by black lines which are saved in a line feature class. My goal is to find the shortest connection between one central point of the building edges and the road axes. The connection line between the building edges and the road axes marked in green and the connection point on the road marked in blue will be saved in feature classes.

I want to automate the following processes, can somebody help:
- determine the central point (red) of each building which is nearest to the road (black)
- determine for each found central point (red) the point on the road axes (blue) which marks the shortest line connection and save these points in a point feature class
- connect these points, each red point with the accompanying blue point, through a line and save these in a line feature class

I work with ArcMap 9.3 and want to realize the automatization of the problem with VBA (version 6.5). If anybody can provide a solution for my problem or even only part of the problem I would be very grateful.