Solidworks macro, some function not working when used through marofeature

Hi,

     I need your help on this! I have a macro that works great. But somewhere in the macro, I delete the sheetmetal folder if it dont contain sheetmetal anymore. It works great when the macro is running alone, but when I use it as macrofeature, when I rebuild it run the macro but this line of code (the only I noticed for now) is not deleting the feature. No error, no message... Is anyone know what it could be?

Thanks 

** Also, I would like to block the macro from running while inside a function and I found nothing to check if inside feature edition. When I insert sheetmetal, the macro start to run from the rebuild function of the macrofeature but its too soon, I would like to wait the end of the function to get the right property...etc If you can help on that one too... ☺️  **