As per title, I am trying to export a Bills of Materials table directly from a assembly file to an excel spreadsheet.
I have been searching though the forums for information that would help me and have found various snippets of information.
The following is some of the code I have extracted from a previous thread:
--------------------------------------------------------------------------------
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 = ""
Const OutputPath As String = "C:\
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swBOMTable = swModel.Extension.InsertBomTable(BOMTemplate, 0, 0, swBomType_e.swBomType_Indented, "")
Set swTable = swBOMTable
swTable.SaveAsText OutputPath & "BOMTable_" & swModel.GetTitle() & ".txt", ","
Set swAnn = swTable.GetAnnotation
swAnn.Select3 False, Nothing
swModel.EditDelete
End Sub
--------------------------------------------------------------------------------
I have managed to get this to work but when I try and modify the code to convert to excel it doesn't work.
I have tried changing the appropriate line of text to the following but it fails when processing the edited line.
swTable.SaveAsExcelFile OutputPath & "BOMTable_" & swModel.GetTitle() & ".xls", ","
Any help would be most appreciated,
Thanks
Kevin