In this thesis the electronic, structural, and magnetic properties of metal complexes are studied, with a focus on the different properties that arise from their interaction with a variety of substrates. The thermal-activated ring-closure reaction that transforms octaethylporphyrin (OEP) metal complexes into tetrabenzoporphyrin (TBP) ones is investigated with x-ray absorption spectroscopy (XAS) and x-ray magnetic circular dichroism (XMCD) for different molecules composed of one of two metal centers, Fe or Co. The changes to the magnetic properties of the complexes are discussed as a result of their interaction with the different substrates (Au(111), Au(100), Cu(111), Cu(100), and graphene on Ni/W(110)). Spin- Hamiltonian formalism is applied in order to obtain further magnetic information about the ion and a comparison to density functional theory (DFT) is also done. The magnetic measurements, performed usually at a temperature T = 4K and external field B = 6T, evidenced clear modifications to the uniaxial anisotropy and magnetic moments of the molecules before and after the ring-closure reaction, as well as among the different substrates. The FeOEP uniaxial anisotropy changes from D = 1.72 meV to D = 0.39 meV within the plane of the molecules after the ring-closure reaction on Au(111), while the magnetic moment remains constant. In the CoOEP molecule the change is even more striking, with the spin magnetic moment being completely quenched after ring closure on the Cu(100) substrate. No spin moment is observed for either Co molecule when deposited on Cu(111). The same techniques are applied to the study of another set of metal complexes, based on lanthanides. Two tris(tetramethylheptanedionate) ((TMHD)3) molecules, with Dy and Er as lanthanide metal centers, were investigated. Sharp variation in the direction and intensity of the uniaxial magnetic anisotropy of the two molecules were identified on different substrates (graphene/Ir(111), graphene/Ni/W(110), HOPG (highly ordered pyrolytic graphite), and Au(111)), with no substantial variation in their magnetic moments. The flexibility of these molecules enables the quantization axis of their 4f orbitals to be rotated, depending on the substrate, so that the Dy molecule exhibits a quantization axis that lays parallel to the substrate when it is deposited on graphene/Ir(111), but rests at an intermediary position on the HOPG substrate, not fully parallel or perpendicular to it. For the Er molecule a similar situation is observed, this time with the substrates graphene/Ni/W(110) and Au(111).