I have a macro that we use on part drawings to create a single item bom. It works great but the only problem is that if a bom already exists on the drawing it just adds another bom over top of the one that is already there. So if someone wants to update the bom and runs the macro again they get two boms rather than it just updating. So I would like to change it so that it just looks if a Solidworks bill of materials already exists and if it does then delete it and then run the macro as normal to add a new bom in.
How would I go about having it check for an existing bom and then deleting it if there is?
I could provide my code for adding the bom but I don't know if it's really even applicable to my question.
Thanks
Try using ClearSelection2 to clear the selection (if any)
2018 SOLIDWORKS API Help - ClearSelection2 Method (IModelDoc2)