as i wrote, it will NOT work from assembly BOM, you must create idw, then place your assembly partlist, and then you can go trough partslist and export it.
for example i created function for that:
you must change idw template and xls template also code sets up partlist style so change it to yours or comment that line - it is for choosing columns to export you can do it also as shown below.
Function exportPL(oAssemblyDoc)
On Error Resume Next
Dim oDrawDoc As DrawingDocument
Dim obom As BOM= oAssemblyDoc.ComponentDefinition.BOM
' Make sure that the structured view is enabled.
obom.StructuredViewEnabled = True
'set the structured view to 'all levels'
obom.StructuredViewFirstLevelOnly = True
Dim oStructuredBOMView As BOMView = obom.BOMViews.Item("Structured")
Dim path As String="C:\"
oStructuredBOMView.Sort ("Part Number", True)
oStructuredBOMView.Renumber
oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, path & "ISS_PL.idw", True) 'PUT HERE YOUR TEMPLATE FULLFILENAME
osheet = oDrawDoc.ActiveSheet
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(1, 1)
obview = osheet.DrawingViews.AddBaseView(oAssemblyDoc, oPoint, 1, kDefaultViewOrientation, kHiddenLineDrawingViewStyle)
Dim opartslist1 As PartsList = osheet.PartsLists.Add(obview, oPoint)
opartslist1 = osheet.PartsLists(1)
opartslist1.Style = oDrawDoc.StylesManager.PartsListStyles.Item("ISS_PL") ' PUT HERE YOU PARTSLIST STYLE OR COMMENT THIS LINE
opartslist1.Sort ("PART NUMBER")
opartslist1.Renumber
opartslist1.PartsListColumns.Add (PropertyTypeEnum.kCustomProperty,"Laser")
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oOptions.Value("Template") = Path & "Szablon XLS.xls" 'PUT HERE YOUR TEMPLATE FULLFILENAME
oOptions.value("StartingCell") = "A12"
'oOptions.Value("TableName") = ThisDoc.FileName(False) 'without extension
oOptions.value("IncludeTitle") = False
'oOptions.Value("ExportedColumns") = "Item;QTY;Part Number;QTY;QTY;Description;Grub.;Szer.;Dł.;Materiał;Laser;Wykrawarka;Gilotyna;Krawędziarka;Piła;Prasa/Wierta.;Zgrzewarka;TokFrez;Magazyn;Masa"
'oOptions.Value("ExportedColumns") = "Item;QTY;Part Number;Description"
oOptions.value("AutoFitColumnWidth") = True
nnname = Mid(oAssemblyDoc.FullFileName, InStrRev(oAssemblyDoc.FullFileName, "\", -1) + 1, Len(oAssemblyDoc.FullFileName) - InStrRev(oAssemblyDoc.FullFileName, "\", -1) - 4)
bomname = Left(oAssemblyDoc.FullFileName, InStrRev(oAssemblyDoc.FullFileName, "\", -1)) & nnname & ".xls"
If Dir(bomname) <> "" Then
Kill (bomname)
Else
End If
opartslist1.Export (bomname, PartsListFileFormatEnum.kMicrosoftExcel, oOptions)
oDrawDoc.Close (True)
If oModel <> ThisApplication.ActiveDocument Then
oModel.Close (True)
End If
End Function
opartslist1.PartsListColumns.Add (PropertyTypeEnum.kCustomProperty,"Laser")