Getting the name of the component to which a note is attached to within a drawing

Hello,

I would like to get the name of the component that a leader note (selected at the time when the macro is run) is attached to.

Here is what I've tried:

Set swNote = swSelMgr.GetSelectedObject6(1, -1)

Set swAnnotation = swNote.GetAnnotation

EntityArray = swAnnotation.GetAttachedEntities3

Set swEntity = EntityArray(0)

Set swComponent = swEntity.GetComponent

namestring = swComponent.Name

It errors out at namestring line because swComponent never gets assigned, it show as "Nothing" in the local variables window.

Thanks in advance!

SolidworksApi/macros