Nigel,
It already does, you get the whole line pasted which Stellarium calls 'Catalogue Number' though
Examples:
A star from Ursa Major - F & M will get - 'Dubhe (α UMa - 50 UMa) - HIP 54061 A'
If it's a star then all you need is the HIP number - Keep 'HIP 54061' and delete the rest.
If you paste M42 data then you'll get this - 'Great Nebula in Orion (M 42 - NGC 1976)'
Just delete everything apart from M42 or in this case NGC1976 even.
Have a go, you'll soon work it out Nigel.
Have Fun
Paul