In most coherent control experiments with femtosecond pulses, the temporal shape of the pulses is maintained throughout the interaction region. Here we show how pulses can be controlled such that their shapes vary rapidly even when propagating very short distances of a few micrometers. This changing pulse shape has a significant effect on coherent nonlinear optical processes. Here we study third-harmonic generation induced by a coherently controlled excitation pulse whose temporal profile changes along the axial coordinate.We show how such manipulations can be used to improve the axial resolution in a multiphoton optical microscope.