Need to select the last item in a design tree

this is what i have so far...

'    Dim swapp As SldWorks.SldWorks

'    Dim part As IModelDoc2

'    Dim addedPart As SldWorks.ModelDoc2

'    Dim assemDoc As SldWorks.AssemblyDoc

'    Dim lerrors As Long

'    Dim lwarnings As Long

'    Dim compcount As Integer

'    Dim boolstatus As Boolean

'    Dim i As Integer

'    Set swapp = Application.SldWorks

'    i = 0

'    Set assemDoc = swapp.ActiveDoc

'    For i = 0 To UBound(assemDoc.GetComponents(False))

'        i = i + 1

'    Next i

'    Set compcount = assemDoc.GetComponents("") 'UBound(assemDoc.GetComponents(False))

'    Set addedPart = assemDoc.GetComponents(False)(i - 1)

'    Set part = swapp.OpenDoc6(addedPart.GetPathName, swDocPART, 1, "", lerrors, lwarnings)

'    boolstatus = part.SaveAs("C:\Users\dodle\Documents\derp\herpenson.sldprt")

'    swapp.QuitDoc (part)

when i run program it gives me a "compile error: object required"

what should i do

if there is a better way to select this object feel free to suggest

SolidworksApi macros