The proper annealing of Ni(51)Mn(28)Ga(21) ribbon alloy gives rise to an increase of the saturation magnetization and of the magnetic order T(C) (up to 20 K) and martensitic transition T(M) (up to 10 K) temperatures. The combined x-ray absorption spectroscopy (XAS) and x-ray magnetic circular dichroism (XMCD) studies indicate that the annealing treatment drives the alloy to a more ordered structure without significantly affecting the local structure in terms of interatomic distances and bonding geometry. By contrast, the annealing strongly affects the near-edge absorption at the Mn K-edge while no effect is observed at either the Ni or Ga K-edge. These results suggest that annealing leads to a modification of the electronic structure of the Mn atoms while that of Ni and Ga atoms remains unvaried. However, strong XMCD signals are detected at both Ni and Ga K-edges whose amplitude increases after annealing. These results point out that despite the change of the magnetic properties of the system being mainly associated with the modification of the electronic properties of the Mn atoms, both Ni and Ga may play a non-negligible role through the polarization of the conduction band.