Hello everyone,
I made a code with the macro recorder in solidworks 2018 and when I launch it I get an error "Object variable or block variable with not defined"
Here's the code
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Dim swActiveView As Object
Set swActiveView = Part.ActiveDrawingView
Dim swBOMTable As Object
Set swBOMTable = swActiveView.InsertBomTable2(False, 1.96979560481769E-02, 0.287303519163763, swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft, swBomType_e.swBomType_TopLevelOnly, "", "C:\Program Files\SolidWorks Corp\SolidWorks\lang\french\bom-standard.sldbomtbt")
boolstatus = Part.EditRebuild3()
boolstatus = Part.Extension.SelectByID2("Objet de détail2@Feuille1", "ANNOTATIONTABLES", 4.85493846196055E-02, 0.280618432055749, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Objet de détail2@Feuille1", "ANNOTATIONTABLES", 5.24196982084557E-02, 0.252470696864111, 0, False, 0, Nothing, 0)
End Sub
The error is located at the line:
Set swBOMTable = swActiveView.InsertBomTable2(False, 1.96979560481769E-02, 0.287303519163763, swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft, swBomType_e.swBomType_TopLevelOnly, "", "C:\Program Files\SolidWorks Corp\SolidWorks\lang\french\bom-standard.sldbomtbt")
And I don't understand why because I created the macro with the same file that I'm using, so it should work.
Thank you in advance for your answers