Importing BOM from .SLDASM into Excel
Importing BOM from .SLDASM into Excel
(OP)
Summary: I wish to automatically obtain the Bill of Materials (BOM) from a SolidWorks assembly file (.SLDASM) and import it into Excel.
I'm somewhat familiar with VBA. I have an Excel file with a list of file location and file names. From here I want to create a connection to SolidWorks (via ADO/DAO? not sure how to do this) and extract the BOM information from the assembly and import it into Excel. There would be no need to physically open up the assembly, just create the connection and export the BOM information.
Thanks in advance!
I'm somewhat familiar with VBA. I have an Excel file with a list of file location and file names. From here I want to create a connection to SolidWorks (via ADO/DAO? not sure how to do this) and extract the BOM information from the assembly and import it into Excel. There would be no need to physically open up the assembly, just create the connection and export the BOM information.
Thanks in advance!






RE: Importing BOM from .SLDASM into Excel
Lenny's AssemblyBOM macro thread559-158093
SW07-SP3
RE: Importing BOM from .SLDASM into Excel
By this, do you mean that you don't want to have to load the assembly into ram at all, or do you mean that you just don't want to have it come up on the screen? I don't think BOM information is available without opening the assembly because the BOM is built dynamically from the assembly.
ADO: ActiveX Data Objects
DAO: Data Access Objects
Neither of these will give you access to information in a SolidWorks file. Only SolidWorks (or to a limited extent, SolidWorks Explorer) can access data in a SolidWorks file. It would be possible to automate SolidWorks using COM to open the assembly, traverse it, and build your own BOM from that data. However, unless you've seriously understated your familiarity with VBA (and the SolidWorks API in particular), I would say that what you've stated that you want to do will require a lot more assistance than it's possible to give in a web forum.
RE: Importing BOM from .SLDASM into Excel
Unfortunately I guess my VBA knowledge really isn't that great... This macro requires that I run it from SolidWorks. Anyone by any chance know how to get started from Excel?
RE: Importing BOM from .SLDASM into Excel
RE: Importing BOM from .SLDASM into Excel
Assuming I have a list of Path + File names of assembly drawings in Column A in an Excel file:
Set swApp = CreateObject("SldWorks.Application")
For i = 1 to Range("A65536").End(xlUp).Row
PathName = Cells(i, 1).Value
Set swPart = swApp.OpenDoc(PathName, swDocDrawing)
'Somehow extract BOM information and export to Excel.
Next i
Can be changed to open Assembly instead of Drawings if that's easier. I'm not sure how BOM information is stored exactly
RE: Importing BOM from .SLDASM into Excel
RE: Importing BOM from .SLDASM into Excel
Macduff![[spin] spin](https://www.tipmaster.com/images/spin.gif)
Colin Fitzpatrick
Mechanical Design Engineer
Solidworks 2007 SP 2.2
Dell 390 XP Pro SP 2
nVida Quadro FX 3450/4000