Try this macro, edit as required. Used Iterate over all part instances codes shared by Artem Taturevych here: https://forum.solidworks.com/message/558867#comment-558867
Thanks for the fast answer, it works perfect.
Is there a macro that runs through the assembly tree and adds a custom property (like PartNo) to the parts and assembly in a way that a subassembly parts ( or subassembly) take prefix number of a subassembly that they belong to (upper assembly)? Is that possible?
And how can you follow the feature tree with the numbers.I tried to repair a Traverse Assembly at Component Level Example macro and works fine with top level components (except the numbers do not follow the assembly tree) but not the parts in subassembly.
What I would like IS :
Thank you in advance fo any answer.