We investigated dibenzo[a,h]thianthrene molecules adsorbed on ultrathin layers of NaCl using a combined low-temperature scanning tunneling and atomic force microscope. Two stable configurations exist corresponding to different isomers of free nonplanar molecules. By means of excitations from inelastic electron tunneling we can switch between both configurations. Atomic force microscopy with submolecular resolution allows unambiguous determination of the molecular geometry, and the pathway of the interconversion of the isomers. Our investigations also shed new light on contrast mechanisms in scanning tunneling microscopy.