error 9 (sometimes)

hi!
i have done a macro to get component's names but sometimes i haveerror9. i don´t understand why appears the error onlysometimes. the code is this:

Dim swchildcomp As SldWorks.Component2
Dim vChildComp As Variant
dim name As String, name2 () As String

vChildComp = swcomp.GetChildren

For j = 0 To UBound(vChildComp)
Set swchildcomp = vChildComp(j)
name = swchildcomp.Name2 'example: name=box/chair-1
name2 = Split(izena, "/") 'example: name2(1)=box; name2(2)=chair-1
name = izena2(UBound(name2)) 'name=chair-1
name = Left(izena, InStrRev(name, "-") - 1) 'name=chair
msgbox name
End j

the error apprears when j=21 and name=empty. Am i doing anymistake?
thanks!SolidworksApi macros