There is a method to make active a sub-assembly for making changes at inside components ?

I want to write a Macro that make parts and sub-assemblies virtual. When the macro traverse the assembly tree, only the first level of assembly work fine; parts inside of sub-assembly cannot be changed because her assembly is not active. Any suggestion ?

SolidworksApi macros