How to sort weldment cut list table with respect to item number

Dear all,

           I have tried to automate the cutlist generation.

Option Explicit

Const WeldmentTableTemplate As String = "C:\Program Files\SolidWorks Corp\SolidWorks\lang\english\cut list.sldwldtbt"

Dim swApp As SldWorks.SldWorks

Dim swmodel As SldWorks.ModelDoc2

Dim WMTable As SldWorks.WeldmentCutListAnnotation

Sub main()

Set swApp = Application.SldWorks

Set swmodel = swApp.ActiveDoc

Dim swdraw As SldWorks.DrawingDoc

Dim swview As SldWorks.View

swApp.DocumentVisible False, 0

Set swdraw = swApp.NewDocument("C:\MECH_PDM\3D CAD\6. SW Data\Templates\Detail A2.drwdot", 0, 0, 0)

Set swview = swdraw.CreateDrawViewFromModelView3(swmodel.GetPathName, "*Front", 0, 0, 0)

Set WMTable = swview.InsertWeldmentTable(False, 0.1996662889191, 0.1013905859662, swBOMConfigurationAnchor_TopLeft, "Default", WeldmentTableTemplate)

Dim swanntable As SldWorks.TableAnnotation

Set swanntable = WMTable

Dim status As Boolean

swdraw.ForceRebuild

WMTable.Sort 0, True

swdraw.ForceRebuild

swanntable.SaveAsText "C:\Users\inmab2\Desktop\svc itemlist\BA.txt", vbTab

Call Saveexcel

'swApp.CloseAllDocuments (True)

End Sub

how to sort the table with respect to ITEM NO. WMTable.Sort 0, True(not working)

its working fine with respect to QTY. WMTable.Sort 1, True

please refer the screen shot and help me to solve this.

Regards

Manikandan.B

SolidworksApi macros