Showing results for 
Search instead for 
Did you mean: 

Copy Parts List contents to a word document

Valued Contributor
Valued Contributor


Does anyone have VB code that will extract data from a parts list or copy contents of a

Solid Edge draft parts list to a text file or word document.  Or knows how to invoke

the "Copy Contents" command in Solid Edge draft?





Posted by: Scott Smith
Post date: 9/13/2011 7:49:15 AM


RE: Copy Parts List contents to a word document

Valued Contributor
Valued Contributor

hi ssdemper

If you are looking at an easy way to extract parts lists from assembly file you can use the reports function (in ST3-under tools>assistants) which will give you all sorts of reports and the ability to mange the info in them.

There are a sew issues concerning getting a parts list from a draft. Since you can have a few different assemblies / parts on a single draft, you can have a few part lists, or should I say a part list per drawing view, so this might require selection of a specific drawing view. Furthermore, the parts list is not automatically exist just because you dropped an assembly on a draft, you need to generate it (home>tables>parts list).


Anyway – here is something I scrambled in vb. You must have a draft file open and only one drawing view selected.

The code gets the active view, generates a parts list, copy it to clipboard and paste it to word and excel. I didn’t take the time to format the word doc but I gave you the possibility to paste to excel (which for me makes more sense as a table). You may select to paste to either – just erase the unwanted part of the code.

Note that the code also removes the parts list from the drawing at the end.



' --- partlist excractor from drawing view by Alon Raviv



'--- solidedge dims


Dim oSE As SolidEdgeFramework.Application 'define Solid edge program

Dim oActDoc As SolidEdgeDocument

Dim oDFT As SolidEdgeDraft.DraftDocument

Dim oDrawView As SolidEdgeDraft.DrawingView

Dim oSelectSet As SolidEdgeFramework.SelectSet

Dim oPLists As SolidEdgeDraft.PartsLists

Dim oPartsList As SolidEdgeDraft.PartsList

Dim oMLink As String


'--- word dims

Dim AppWord As Word.Application

Dim oWord As Word.Document


'--- excel dims

Dim AppExcel As Excel.Application

Dim oWb As Workbook

Dim oWs As Worksheet


Sub main()



Set oSE = GetObject(, "solidedge.application") 'calling solidedge application

Set oActDoc = oSE.ActiveDocument 'calling the active document

Set oSelectSet = oSE.ActiveSelectSet



If oActDoc.Type igDraftDocument Then 'testing for draft file only

MsgBox ("Solidedge active file must be a draft!")

Exit Sub


ElseIf (oSelectSet.Count 1) And (oSelectSet.Type igDrawingView) Then 'testing for 1 drawing view is selected

MsgBox ("You must select one drawing view!")

Exit Sub


End If


Set oDrawView = oSelectSet(1)


Set oDFT = oActDoc

Set oPLists = oDFT.PartsLists


Set oPartsList = oPLists.Add(oSelectSet(1), "ISO", 0, 1) 'create parts list to the view selected



' here starts word paste


Set AppWord = CreateObject("Word.Application")

AppWord.Visible = True

Set oWord = AppWord.Documents.Add



' here starts excel paste

Set AppExcel = CreateObject("Excel.Application")

AppExcel.Visible = True

Set oWb = AppExcel.Workbooks.Add

Set oWs = AppExcel.ActiveSheet






MsgBox "Done"


End Sub



Posted by: alon raviv
Post date: 9/14/2011 2:58:51 AM