Export Parts list to excel

Export Parts list to excel

ober2558
Enthusiast Enthusiast
373 Views
1 Reply
Message 1 of 2

Export Parts list to excel

ober2558
Enthusiast
Enthusiast

I would like a code that exports the active drawing sheets parts list to an excel file in the same location as the drawing and with a user inputted name.

0 Likes
Accepted solutions (1)
374 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Maybe this will work as you wanted.  There are still more options we could have filled in though, if needed.

https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=PartsList_Export 

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim oPList As PartsList = Nothing
	Try : oPList = oDDoc.ActiveSheet.PartsLists.Item(1) : Catch : End Try
	If oPList Is Nothing Then Exit Sub
	Dim sPath As String = ThisDoc.Path
	Dim sDefaultName As String = ThisDoc.FileName(False)
	Dim sFileName As String = InputBox("Enter PartsList Excel File Name.", "Exported PartsList File Name", sDefaultName)
	Dim sExcelFile As String = sPath & "\" & sFileName & ".xlsx"
	oPList.Export(sExcelFile, PartsListFileFormatEnum.kMicrosoftExcel)
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)