I want to communicate information between SolidWorks and Excel using vba back and forth. I managed
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim myLength As Object
Dim BossExtrude As Object
'MAIN FUNCTION
Sub SolidworksToExcel()
'Access active Solidworks and Excel files
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set xl = GetObject(, "Excel.Application")
Set xlsh = xl.ActiveSheet
'Determine length
Set myLength = Part.Parameter("D1@Distance3@Mold_Assembly.SLDASM")
'Send to specific cell in Excel
xlsh.Cells(6, 4).Value = myLength.SystemValue * 1000
End Sub
This code prints a set distance in cell (6,4).
Now, I want to print the amount of a features with the similar name in my assembly in a certain cell. For example in cell (7,4).
A part of my Solidworks feature tree looks like the following:
I want to know the amount of unsuppressed features that start with “Ejector Large [10mm]”, even though they are not exactly within the same folder. To be clear, based on the image, it should display “2” in my excel, as there are two unsuppressed Ejector features in my image.
Can someone give me advice on how to accomplish this? Please do not hesitate to ask questions if anything is unclear.
Thank you in advance.