Parts List Expand if Description Contains Certain Info

Parts List Expand if Description Contains Certain Info

KWarrenCA
Advocate Advocate
227 Views
1 Reply
Message 1 of 2

Parts List Expand if Description Contains Certain Info

KWarrenCA
Advocate
Advocate

I have this code that expands the parts list of all assemblies. I want to change it to only expand rows when the description for the item contains "FIELD FABRICATE". Currently it will expand all items no matter what.

On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

''BOM sorting
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)

Dim oRow As PartsListRow

''Parts List 1 To sort

If oPartsList1.Title = "PART LIST (PURCHASED)" Then
	For Each oRow In oPartsList1.PartsListRows
		If oRow.Item("DESCRIPTION").contains = "FIELD FABRICATE" Then
			oRow.Expanded = True
		End If
	Next
	oPartsList1.Sort2("VENDOR", 1, "STOCK NUMBER", 1, "SIZE", 1, AutoSortOnUpdate, True)
End If
ThisApplication.ActiveView.Fit

  

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

A.Acheson
Mentor
Mentor
Accepted solution

Hi @KWarrenCA 

 

You were nearly there. Your just missing retrieving the value from the cell object and also the string contains method needs to be as shown. 

AAcheson_0-1708966801476.png

 

If oRow.Item("DESCRIPTION").Value.Contains("FIELD FABRICATE") Then
   oRow.Expanded = True
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan