The automatic programming apparatus has the determining unit 340 that determines whether the machine tool to be controlled has a sub-spindle, and the determining unit 340 determines, at the time of startup of the program, whether the machine tool to be controlled is a machine with a sub-spindle (second spindle) (step S400).