I went to the Renfe office in Madrid to buy train tickets. I had the impression that you could buy any tickets at the office. It's located right behind the Banco de Espana. I didn't look for an office in Barcelona, but there might very well be one.
Hope this helps.
Cristi