If your BOMView is sorted by item numbers in ascending order then the following sample will swap rows 2 and 3.
Sub SWAP_Rows()
Dim oAssyDoc As AssemblyDocument
Set oAssyDoc = ThisApplication.ActiveDocument
Dim oAssyDef As AssemblyComponentDefinition
Set oAssyDef = oAssyDoc.ComponentDefinition
' Get the Representations Manager object.
Dim repMgr As RepresentationsManager
Set repMgr = oAssyDef.RepresentationsManager
' activate LOD Master - necessary to get BOM object !!!
Dim oMasterLOD As LevelOfDetailRepresentation
Set oMasterLOD = repMgr.LevelOfDetailRepresentations.Item(1)
oMasterLOD.Activate
'set a reference to the BOM
Dim oBOM As BOM
Set oBOM = oAssyDef.BOM
' Make sure that the "Parts Only" view is enabled.
oBOM.PartsOnlyViewEnabled = True
Call oBOM.SetPartNumberMergeSettings(True)
'set a reference to the "Parts Only" BOMView
Dim oBOMView As BOMView
Set oBOMView = oBOM.BOMViews.Item("Parts Only")
Dim oBOMRow1 As BOMRow
Set oBOMRow1 = oBOMView.BOMRows.Item(2) 'item number = 2
Dim oBOMRow2 As BOMRow
Set oBOMRow2 = oBOMView.BOMRows.Item(3) 'item number = 3
'swap item numbers
oBOMRow1.itemNumber = 3
oBOMRow2.itemNumber = 2
Beep
End Sub
cheers,
Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network