Refractive microlenses are nowadays widely used in optical systems. Characterizing their surface is essential to ensure their quality and to optimize their fabrication process. This is realized by optical surface profilers thanks to their vertical resolution, short measurement time and areal information. However, when measuring non-flat surfaces, errors appear caused by aberrations of the microscope objective used in such systems, which significantly limit the achievable quality of the manufactured spherical surfaces. Approaches have been proposed to tackle these errors, but none of them demonstrated its validity for measurements of high quality microlenses. In this work, we demonstrate that the surface error depends on the surface position within the field of view of the microscope objective and on the surface slope. We then explain how to record the value of this error experimentally: this can be done by measuring a reference ball placed at different positions in the field of view. We finally use a machine learning algorithm to fit the experimental data in order to correct subsequent measurements. We apply this approach to measurements performed by a 20× numerical aperture 0.6 microscope objective of a confocal microscope. The effectiveness of the proposed method is demonstrated by showing that the surface error corresponds to a RMS wavefront error of λ/7 before correction and of λ/50 after correction for glass microlenses used in the visible range. This method thus allows the use of high numerical aperture microscope objectives for an accurate characterization of microlenses. Likewise, the fabrication capability of microlenses in terms of slope and quality is greatly extended, which is especially important for aspheres or freeforms.