I use matched sampling techniques to analyze whether firms that start exporting become more productive. To this end, I use micro data of Slovenian manufacturing firms operating between the period 1994-2000. I estimate total factor productivity using the Olley-Pakes correction for sample selection and for potential endogeneity of the input factors. In most sectors I find evidence supporting the learning by exporting hypothesis controlling for the self-selection process explicitly. Exporting firms become on average 20 percent more productive once they start exporting. This result is robust to other controls that may be associated with increased productivity, such as private ownership. Finally, I introduce export as a state variable in the dynamic program of the firm and allow exporting firms to face different market structures and factor prices. This leads to a modification in the Olley and Pakes estimation algorithm. The results of learning by exporting are - if anything - even stronger.