Class ThisRule Public i As Long Sub Main() Dim oAssDoc As AssemblyDocument oAssDoc = ThisApplication.ActiveDocument Dim oCompDef As AssemblyComponentDefinition oCompDef = oAssDoc.ComponentDefinition Dim oOcc As ComponentOccurrence Dim strExcelPath As String strExcelPath="D:\bb.xlsx" 'Please create one excel file before running the code, and define the location of excel here oExcelApp = GoExcel.Application GoExcel.CellValue(strExcelPath, "Sheet1", "A1")= "Part Name" GoExcel.CellValue(strExcelPath, "Sheet1", "B1")= "X" GoExcel.CellValue(strExcelPath, "Sheet1", "C1")= "Y" GoExcel.CellValue(strExcelPath, "Sheet1", "D1")= "Z" i=2 For Each oOcc In oCompDef.Occurrences Call GetCOG(oOcc,strExcelPath) Next GoExcel.Save GoExcel.Close End Sub Function GetCOG(oOcc As ComponentOccurrence, s as String) If oOcc.DefinitionDocumentType = kPartDocumentObject Then Dim oMassProps As MassProperties Dim oPartDoc As PartDocument oPartDoc = oOcc.Definition.Document If oPartDoc.ComponentDefinition.SurfaceBodies.Count > 0 Then oMassProps = oOcc.MassProperties GoExcel.CellValue(s, "Sheet1", "A" & CStr(i))= oOcc.Name GoExcel.CellValue(s, "Sheet1", "B" & CStr(i))= oMassProps.CenterOfMass.X GoExcel.CellValue(s, "Sheet1", "C" & CStr(i))= oMassProps.CenterOfMass.Y GoExcel.CellValue(s, "Sheet1", "D" & CStr(i))= oMassProps.CenterOfMass.Z i=i+1 End If End If If oOcc.SubOccurrences.Count > 0 Then For Each oOcc In oOcc.SubOccurrences Call GetCOG(oOcc,s) Next End If End Function End Class