Think i have worked this out. This code seems to work anyway. The actual selected object is a in-out parameter, not the return value. The return value is the selected object's type, which you can test and set the object to an appropriate typed variable, should you require.
Someone can correct me if i am wrong.
Public Sub Addin_MenuClick(Repository As EA.Repository, ByVal MenuName As String, ByVal ItemName As String)
Dim selectedObject As Object
Dim selectedObjectType As EA.ObjectType
If (ItemName = COMP_DETAILS_COMMAND) Then
selectedObjectType = Repository.GetTreeSelectedItem(selectedObject)
MsgBox selectedObject.Name