The Excel BOM can be exported but is a 'pig' to work with on screen within SW. I seem to remember before 2006 that you could work on a Excell BOM outside SW and so save on all the graphic problems of scalling it to be visible on a screen oir am I dreaming.
SW BOM easier to use on screen - but can I export it so I can import data into a seperate word file or excell file for documentation?
in sw2005 you could save the BOM as ".txt" file, then import that into Excel. Everything is fine except column widths, and text justification, both of which just takes a few seconds to redo in Excel. I would assume sw2006 still does this.
Below you find the macro is use for exporting directly into excel for further processing. It is snatched from from the api help and just slightly modified. All it does is open excel and copy the bom into a new sheet (SWX2005).
Public Enum swBOMConfigurationAnchorType_e swBOMConfigurationAnchor_TopLeft = 1 swBOMConfigurationAnchor_TopRight = 2 swBOMConfigurationAnchor_BottomLeft = 3 swBOMConfigurationAnchor_BottomRight = 4 End Enum
Public Enum swBomType_e swBomType_PartsOnly = 1 swBomType_TopLevelOnly = 2 swBomType_Indented = 3 End Enum
Public Enum swTableSplitDirection_e swTableSplit_None = 0 swTableSplit_Horizontal = 1 swTableSplit_Vertical = 2 End Enum
Dim xlApp As Object
Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swDraw As SldWorks.DrawingDoc Dim swSheet As SldWorks.Sheet Dim swFeat As SldWorks.Feature Dim swBomFeat As SldWorks.BomFeature Dim sPathName As String Dim nNumSheet As Long Dim nRetval As Long Dim i As Long Dim bIsFirstSheet As Boolean Dim bRet As Boolean
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swDraw = swModel bIsFirstSheet = True
Set xlApp = Nothing On Error Resume Next Set xlApp = GetObject(, "Excel.Application") On Error GoTo 0 If xlApp Is Nothing Then Set xlApp = CreateObject("Excel.Application") End If
xlApp.Visible = True xlApp.Workbooks.Add
Set swFeat = swModel.FirstFeature Do While Not swFeat Is Nothing If "BomFeat" = swFeat.GetTypeName Then Set swBomFeat = swFeat.GetSpecificFeature2 ProcessBomFeature swApp, swModel, swBomFeat End If Set swFeat = swFeat.GetNextFeature Loop For i = 1 To 5 xlApp.ActiveWorkbook.ActiveSheet.Columns(i).AutoFit Next i Set xlApp = Nothing End Sub
Sub ProcessBomFeature(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, _ swBomFeat As SldWorks.BomFeature)
Dim swFeat As SldWorks.Feature Dim vTableArr As Variant Dim vTable As Variant Dim swTable As SldWorks.TableAnnotation Set swFeat = swBomFeat.GetFeature
vTableArr = swBomFeat.GetTableAnnotations For Each vTable In vTableArr Set swTable = vTable ProcessTableAnn swApp, swModel, swTable Next vTable End Sub
Sub ProcessTableAnn(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, _ swTableAnn As SldWorks.TableAnnotation)
Dim nNumRow As Long Dim nNumCol As Long Dim nNumHeader As Long Dim sHeaderText() As String Dim i As Long Dim j As Long Dim k As Long Dim nIndex As Long Dim nCount As Long Dim nStart As Long Dim nEnd As Long Dim nSplitDir As Long
nNumHeader = swTableAnn.GetHeaderCount nSplitDir = swTableAnn.GetSplitInformation(nIndex, nCount, nStart, nEnd) If swTableSplit_None = nSplitDir Then nNumRow = swTableAnn.RowCount nNumCol = swTableAnn.ColumnCount nStart = nNumHeader nEnd = nNumRow - 1 Else nNumCol = swTableAnn.ColumnCount If 1 = nIndex Then nStart = nStart + nNumHeader End If End If
ReDim sHeaderText(nNumCol - 1) For j = 0 To nNumCol - 1 xlApp.ActiveWorkbook.ActiveSheet.Cells(1, j + 1).Value = swTableAnn.GetColumnTitle(j) sHeaderText(j) = swTableAnn.GetColumnTitle(j) Next j
For j = nStart To nEnd For k = 0 To nNumCol - 1 xlApp.ActiveWorkbook.ActiveSheet.Cells(j + 1, k + 1).Value = swTableAnn.Text(j, k) Next k Next j End Sub
If you find it takes more than a few seconds to tart it up in Excel, then what I do is open up the exported text file in Excel, copy all the relevant cells to the clipboard, then open up a fully formatted template and use "paste special" with the "values" option to paste the data whilst retaining the formatting.
I had this problem a while back and our local dealer had to scatch his head for a while. It's somewhere you would never think to look, For the life of me I cannot see why programmers do this sort of shit to the users??
Right click on BOM Table Header at top Choose Save as Template, Under save as type there are options for