I'm using the code below to try to create a BOM using the API:
Sub main()
Dim swBOMTable As SldWorks.BomTableAnnotation, BOMTemplate As String
BOMTemplate = "\\Server\path\to\bom-standard.sldbomtbt"
Set swBOMTable = Application.SldWorks.ActiveDoc.Extension.InsertBomTable(BOMTemplate, 0, 0, _
swBomType_e.swBomType_TopLevelOnly, "")
End Sub
However, when line #5 executes, the swBOMTable is empty and no BOM is created. This is somewhat mystifying to say the least because this is essentially the code that was created with the macro recorder when I recorded myself adding a BOM to an open SW assembly. It seems like this should be fairly straightforward. I believe the above code above is the recommended means of creating a BOM with the API according to a couple different answers I've found (Example #1, Example #2). I can't figure out what I'm doing differently to cause it not to work in my case.
Tim,
This is just an anecdote, I can't see what is wrong with the code that you posted, but maybe it is useful information. The following is from a macro that I use for exporting BOMs to excel from assembly models.
I don't recall if passing an empty string argument for the configuration worked for me. This might be why I chose to use "Default" in that example; I would certainly prefer not to force the assembly to contain a specific named configuration in order for the macro to work.
Edit: Actually, in the link that you posted, the (unmarked) correct answer was that the OP had not specified a configuration.
Macro: Generate BOM, Export to Excel