Yes, I would like to generate an .xls file with (4) columns and as many rows as distinct cut list items. I am really looking for something to save me from right clicking and manually saving it. Any info would be helpful.
The attached macro will give you two options for solving this problem:
SaveSelectedTable - if you assign your macro button to this method, the selected table will be saved.
SaveFirstTable - if you assign your macro button to this method, the first weldment the macro encounters will be saved.
Use the steps outlined here to set up a macro button. Then use Tools-->Customize to assign a keyboard shortcut to that macro button.
Open the macro using Tools-->Macro-->Edit and find the "SAVE_FOLDER" constant and change the desired default save directory. Otherwise you could modify the macro to always save to the folder containing the active drawing. Use IModelDoc2::GetPathName to get that directory.
Unfortunately, there is no method that will save as an XLS, but you can specify the .xls extension using ITableAnnotation::SaveAsText. The problem is that the file is still technically a text file, only with an .xls extension, so when you open the file you'll get this:
You will need to resave the file as an XLS if you want to avoid this dialog on future openings.
save table as xls.swp.zip 11.6 KB
Thank you for your contributions, I am going to give all of these a try this weekend. I will let you know if I need more assistance.
Sure. If someone's answer solved your problem, please mark it as correct. It is much appreciated and helps others know that the issue was resolved.
I need you to pretend that when is comes VBA I'm not as dumb as a Rock but I am. I installed your macro as instructed and followed your link to the other page to set up the Macro command button. I set it to save the first table it came across. Then I ran the Macro and I got a run time error 13 "Type Mismatch". When I hit the debug button Visual Basics opened and I have a yellow arrow and highlighted text at Set swDraw = swModel and this is where I am stuck. Like I said, dumb as a Rock.
Make sure you're using the macro in a drawing.
I have always wanted to tell that 5 years ago I taught myself Solidworks or should I say you taught me Solidworks. I am truly grateful for your input to this forum and I must say you are a Solidworks god. Thank you. No, I am not running it in a Drawing. I have been trying to run it in a multibody weldment which explains a lot. Thank you. Any suggestions on where I can find a Macro that will pull the cut list properties out of a multibody part?
Kenneth Kobmann pulling values out of cut list folder from model could be cumbersome since you may not want to pull every single property. So better put a quick drawing and add the cut list with the required properties and export the table out.
But yes macro can be made to pull the values out of model and export to an excel sheet.
I have a master assembly that is made up 10 "Main Sub-Assemblies" of which 3 are SW Assemblies containing 2-3 sub-(sw)assemblies in each of them and then I also have 7 multibody parts that are acting like assemblies. I just wrapped up the designer part and I'm going to start detailing Monday. I receive a call from my boss tonight telling me I need to submit my purchase request for bought items Monday morning. So, I have been trying to figure out how to export the cut list and/or BOM items so I can filter the purchased items. I have like 550 purchased items I need to have to purchasing Monday morning. There's no way I can have all the drawings done by Monday.
Please try this..and change the SaveAsText path...after saving open XL...it may give you some message say..YES..XL will open..
Sub ProcessTable(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, swTable As SldWorks.TableAnnotation)
Dim swAnn As SldWorks.Annotation
Dim nNumCol As Long
Dim nNumRow As Long
Dim sRowStr As String
Dim i As Long
Dim j As Long
Set swAnn = swTable.GetAnnotation
Dim boolsatus As Boolean
boolsatus = swTable.SaveAsText("D:\test.xls", "")
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swTable As SldWorks.TableAnnotation
Dim bRet As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
'Debug.Print "File = " & swModel.GetPathName
' Get the first view
Set swView = swDraw.GetFirstView
Do While Not swView Is Nothing
' Show the name of the view
' Debug.Print " " & swView.Name
' Get the first table annotation for this view
Set swTable = swView.GetFirstTableAnnotation
Do While Not swTable Is Nothing
ProcessTable swApp, swModel, swTable
' Get next table annotation for this view
Set swTable = swTable.GetNext
' Get the next view
Set swView = swView.GetNextView