insert bom table with documentvisible = false

Hi Guys,

Is there anyway to insert a bom table in an assemble while using the documentvisible property set to false

my solidworks keep crashing every time i get to this line when I use the documentvisible = false

Set SwBOMtable = SwModelDoc.Extension.InsertBomTable(SwBOMTemplatePath, 0, 0, swBomType_e.swBomType_TopLevelOnly, SwConfig(0))

this line work perfectly when the document is visible.

Thanks alot for your time!

Yannick

SolidworksApi macros