The need is: I open an assembly file in solidworks 2018 SP5, I click on the macro button, I have the list, the hierarchical level and the quantity of the components of the assembly in an array variable or in debug print
In addition to the @remrem idea (which I welcome), here is a solution proposed these days by @JeromeP https://www.lynkoa.com/forum/solidworks/exportation-vba-nomenclature-solidworks-vers-excel. However, this is not from the BOM EPDM but by comparing the code of the two proposals you should achieve your goals.
Why not go and get the BOM directly in Epdm, see HERE.
Otherwise there is the possibility to create a BOM in the assembly, extract it to Excel (or other) and then delete this BOM, to do this see the link given by Zozo_mp or the macro given HERE by adding the rows to delete the BOM at the end of the processing.
Otherwise, by going through the analysis of the Feature Manager you have this example that can help you.