VBA Query: VBA script in CATIA to rearrange the order of sub-products within an assembly

Hello, I am working with a VBA script in CATIA to rearrange the order of sub-products within an assembly. I'm using oProduct.Products.Add() to create new sub-products and add them to the parent product, but this approach is not working as expected.

Specifically:

  • I'm extracting numbers from the Part Numbers of the sub-products to determine the desired order.
  • I'm removing all existing sub-products from the parent product.
  • I'm then trying to create new sub-products and add them back to the parent product in the desired order using oProduct.Products.Add().

However, this oProduct.Products.Add() operation does not seem to be creating the sub-products as intended.

I would like to:

  • Understand why oProduct.Products.Add() is not working in my case.
  • Find an alternative method to effectively add the sub-products to the parent product in the desired order.