The customization of AutoCAD with VBA is performed upon the data analysis of railway longitudinal section, and an auto-drawing system for this kind of drawings is realized. Firstly, the data related to the longitudinal section are organized to several Excel lists; then, the communication between AutoCAD and Excel is built; finally, the access of Excel lists is realized according to Excel-VBA mode.