Hello Jelte,
thank you very much for your help, the code works flawless. Below, please find some bits I added to export the results to Excel.
Could you please help me again to also export the name of the missing component to the same Excel table? Unfortunately, I was not able to figure that out by myself.
Thanks again, much appreciated.
Best regards
Fabian
'Variablen
Dim RefPartList As New ArrayList()
Dim XLSXfolder, XLSXfileName, XLSXfile, XLSXtable As String
Dim XLSXrowBegin, XLSXrow As Integer
'Komponenten mit defekter Ableitung finden
Dim doc As AssemblyDocument = ThisDoc.Document
Dim partDefs = doc.AllReferencedDocuments.Cast(Of Document).
Where(Function(refDoc) refDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject).
Where(Function(refDoc) refDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count <> 0).
Where(Function(refDoc) refDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).LinkedToFile <> True).
ToList()
For Each refDoc As PartDocument In partDefs
RefPartList.Add(refDoc)
Next
'Excel Export
XLSXfolder = "C:\Inventor-Zusammenfassungen\"
XLSXfileName = "test.xlsx"
XLSXfile = XLSXfolder & XLSXfileName
XLSXtable = "Tabelle1"
'Startzeile in Excel-Arbeitsblatt
XLSXrowBegin = 1
XLSXrow = XLSXrowBegin + 1
GoExcel.CellValue(XLSXfile, XLSXtable, "A" & XLSXrowBegin) = "Ableitung mit fehlender Referenz"
'Komponente mit defekter Ableitung
XLSXrow = XLSXrowBegin + 1
For Each refDoc In RefPartList
CellFileName = "A" & XLSXrow
GoExcel.CellValue(XLSXfile, XLSXtable, CellFileName) = refDoc.DisplayName
XLSXrow = XLSXrow + 1
Next
GoExcel.Save
MessageBox.Show("Fertig", ":-)", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)