I use this code to Sort it
Try
Dim SheetsNumber
SheetsNumber = ThisApplication.ActiveDocument.Sheets.Count
For i = 1 To SheetsNumber
Dim oPartslistCheck As PartsList
oPartslistCheck = ThisApplication.ActiveDocument.Sheets(i).PartsLists(1)
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Call oDoc.SelectSet.Select(oPartslistCheck)
InventorVb.RunMacro("ApplicationProject", "PartsListSort", "FormatSelectedPartsList")
Next
Catch
End Try
...VBA Code
Option Explicit
Option Base 1
Public Function GetActiveDrawing() As DrawingDocument
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
Set GetActiveDrawing = ThisApplication.ActiveDocument
Else
MsgBox "Must have a drawing active", vbOKOnly, "Error"
End If
End Function
Public Function GetSelectedPartsList() As PartsList
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = GetActiveDrawing
If oDrawDoc Is Nothing Then Exit Function
Dim oSelectSet As SelectSet
Set oSelectSet = oDrawDoc.SelectSet
If oSelectSet.Count = 0 Then Exit Function
If oSelectSet.Item(1).Type <> kPartsListObject Then Exit Function
Set GetSelectedPartsList = oSelectSet.Item(1)
End Function
Public Function FormatPartsList(oPartsList As PartsList) As PartsList
On Error Resume Next
oPartsList.Sort "PART NUMBER", True
oPartsList.Renumber
oPartsList.SaveItemOverridesToBOM
If Err Then
Err.Clear
MsgBox "Could not sort Parts List", , "Error"
End If
Set FormatPartsList = oPartsList
End Function
Public Sub FormatSelectedPartsList()
Dim oPartsList As PartsList
Set oPartsList = GetSelectedPartsList
If oPartsList Is Nothing Then Exit Sub
FormatPartsList oPartsList
End Sub