Try this code:
Sub main
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oPane As BrowserPane = oDoc.BrowserPanes.Item("Model")
Dim oOccs As ComponentOccurrences = oDef.Occurrences
Dim oTM As Transaction = ThisApplication.TransactionManager.StartTransaction(oDoc, "Explode Assembly")
ReturnStep :
For Each oOcc As ComponentOccurrence In oOccs
Dim oRefDoc As Document = oOcc.Definition.Document
If oRefDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject _
Or Not oRefDoc.IsModifiable Then Continue For
Dim oTargetNode As BrowserNode = oPane.GetBrowserNodeFromObject(oOcc)
For Each oSubOcc As ComponentOccurrence In oOcc.SubOccurrences
If oSubOcc.DefinitionDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
Try : oSubOcc.Name = oOcc.Name & " - " & oSubOcc.Name : Catch : End Try
End If
Dim oSourceNode As BrowserNode
oSourceNode = oPane.GetBrowserNodeFromObject(oSubOcc)
Try : Call oPane.Reorder(oTargetNode, True, oSourceNode) : Catch : End Try
Next
oOcc.Delete()
Next
If HasSubAsm(oOccs) Then GoTo ReturnStep
oTM.End()
End Sub
Private Function HasSubAsm(ByVal oOccs As ComponentOccurrences) As Boolean
For i As Integer = 1 To oOccs.Count
If oOccs(i).DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Return True
Next i
Return False
End Function
The new name of the component is written in line 15.