Error while using InsertBomTable4

Hello

I try to insert a bom table by macro.

I use this code and it stops safter the bom table is insert with a "Runtime Error 91: Object variable or with block variable not set"

Anyone have a idea what wrong?

--------------------------------------------------------------------------------------------------------------------------------------------------------

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2

Dim swView As SldWorks.View

Dim swBOMAnnotation As SldWorks.BomTableAnnotation

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

Set swView = swModel.GetCurrentSheet.GetViews()(0)

swBOMAnnotation = swView.InsertBomTable4(False, 0.43, 0.297, 1, 3, "", "T:\\....sldbomtbt", False, 1, True)

swBOMAnnotation.Dissolve (1)

End Sub

--------------------------------------------------------------------------------------------------------------------------------------------------------

SolidworksApi/macros