To realize molecular spintronic devices, it is important to externally control the magnetization of a molecular magnet. One class of materials particularly promising as building blocks for molecular electronic devices is the paramagnetic porphyrin molecule in contact with a metallic substrate. Here, we study the structural orientation and the magnetic coupling of in-situ-sublimated Fe porphyrin molecules on ferromagnetic Ni and Co films on Cu(100). Our studies involve X-ray absorption spectroscopy and X-ray magnetic circular dichroism experiments. In a combined experimental and computational study we demonstrate that owing to an indirect, superexchange interaction between Fe atoms in the molecules and atoms in the substrate (Co or Ni) the paramagnetic molecules can be made to order ferromagnetically. The Fe magnetic moment can be rotated along directions in plane as well as out of plane by a magnetization reversal of the substrate, thereby opening up an avenue for spin-dependent molecular electronics.