Sub GetMasterPart()
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Dim oAsmDef As AssemblyComponentDefinition
Set oAsmDef = oAsmDoc.ComponentDefinition
'ссылка по имени на конкретный компонент (деталь А)
Dim oOcc As ComponentOccurrence
Set oOcc = oAsmDef.Occurrences.ItemByName("Деталь А")
' Через производный компонент в компоненте А
' найдем ссылку на документ детали B
Dim oRefComps As ReferenceComponents
Set oRefComps = oOcc.Definition.ReferenceComponents
'здесь полагаем, что искомый производный компонент
'является первым у детали А
Dim oDerPartComp As DerivedPartComponent
Set oDerPartComp = oRefComps.DerivedPartComponents.Item(1)
' дескриптор документа в производном компоненте
' дает ссылку на документ мастер-детали B
Dim oMasterDocDescriptor As DocumentDescriptor
Set oMasterDocDescriptor = oDerPartComp.ReferencedDocumentDescriptor
Dim oMasterDoc As PartDocument
Set oMasterDoc = oMasterDocDescriptor.ReferencedDocument
Debug.Print oMasterDoc.FullFileName
Beep
End Sub