How hard it is depends on your set up.
Typically you use a matrix to figure out where an indivual entity is in a blockreferene or xref as the block gives you the info at zero rotation and origin zero.
If your xref is at a scale of 1, has an origin 0,0,0 , isnt rotated and has a normal 0,0,1 then there is no need for a matrix.
The code below assumes all that (use a selset function) and uses an xref with only 1 rectangle in it.
Sub SELFROMX()
Dim x As AcadExternalReference
Dim B As AcadBlock
Dim SS As AcadSelectionSet
Dim xname As String
xname = "3"
Set SS = SSet(2, xname)
If SS.count <> 1 Then Exit Sub
Set x = SS(0)
SS.Delete
Dim E As AcadEntity, P As AcadLWPolyline
For Each E In ThisDrawing.Blocks(xname)
If TypeOf E Is AcadLWPolyline Then
Set P = E
Exit For
End If
Next
Dim P1(2) As Double, P2(2) As Double
P1(0) = P.Coordinate(0)(0)
P1(1) = P.Coordinate(0)(1)
P1(2) = P.Elevation
P2(0) = P.Coordinate(2)(0)
P2(1) = P.Coordinate(2)(1)
P2(2) = P.Elevation
Set SS = ThisDrawing.SelectionSets.Add("SS")
SS.Select acSelectionSetWindow, P1, P2
Debug.Print SS.count
End Sub