1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Sub Parcours_Arbre(myProd As Product, nbLevel As Long, chaineAModifier As String)
Dim mySubProd As Products
Dim myChildProd As Product
Dim strTmp As String
Dim index As Long
Set mySubProd = myProd.Products
myProd.ApplyWorkMode DESIGN_MODE
If mySubProd.Count >= 1 Then
For index = 1 To mySubProd.Count
If Is_It_Part(mySubProd.Item(index)) = True Then
strTmp = mySubProd.Item(index).PartNumber
' enlève la chaine demandée du nom de la 'Référence' du 'Produit'
If InStr(1, strTmp, chaineAModifier, 1) <> 0 Then
strTmp = Replace(strTmp, chaineAModifier, "", 1, 1, vbTextCompare)
mySubProd.Item(index).PartNumber = strTmp
End If
' enlève la chaine demandée du 'Nom de l'instance' du 'Composant'
strTmp = mySubProd.Item(index).Name
If InStr(1, strTmp, chaineAModifier, 1) <> 0 Then
strTmp = Replace(strTmp, chaineAModifier, "", 1, 1, vbTextCompare)
mySubProd.Item(index).Name = strTmp ' <================ ICI... ==============>
End If
' enlève tout ce qu'il y a après le 1er "_" du 'Nom de l'instance' du 'Composant'
strTmp = mySubProd.Item(index).Name
If InStr(1, strTmp, "_", 1) <> 0 Then
strTmp = Mid(strTmp, 1, InStr(1, strTmp, "_", 1) - 1)
mySubProd.Item(index).PartNumber = strTmp ' <============ et ICI ============>
End If
Else
Set myChildProd = mySubProd.Item(index)
strTmp = myChildProd.PartNumber
strTmp = Replace(strTmp, chaineAModifier, "", , , vbTextCompare)
myChildProd.PartNumber = strTmp
Parcours_Arbre myChildProd, nbLevel + 1, chaineAModifier
End If
Next
End If
End Sub |
Partager