Hi,
I have quite some experience in VBA programming in Excel/Access/Outlook, but I'm completely new to VBA-programming in Solidworks and it seems I'm overlooking some very basic knowledge, because I've found a quite straight forward macro on this forum to export a specific bom-template, see below, but sadly it doesn't come past the third line...
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swBOMTable As SldWorks.BomTableAnnotation
Dim swTable As SldWorks.TableAnnotation
Dim swAnn As SldWorks.Annotation
Const BOMTemplate As String = "I:\Templates\Tables\Standard Bom\bom-export.sldbomtbt"
Const OutputPath As String = "G:\Stuklijsten\"
Dim ConfigName As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
ConfigName = swModel.GetActiveConfiguration.Name
Set swBOMTable = swModel.Extension.InsertBomTable(BOMTemplate, 0, 0, swBomType_e.swBomType_Indented, ConfigName)
Set swTable = swBOMTable
swTable.SaveAsText OutputPath & "BOMTable_" & swModel.GetTitle() & ".xls", vbTab
Set swAnn = swTable.GetAnnotation
swAnn.Select3 False, Nothing
swModel.EditDelete
End Sub
Can somebody figure out why I keep getting the run time error '91 Object variable or With block variable not set, this would be very much appreciated...
SolidworksApi macros