It turns out it was not rocket science. This is the code I have in an Excel Spread sheet. Note that I used a literal string for "fs.lookin". Anyone using it would have to change this according to their needs. If you have a lot of files to go through, this thing can take a while. You need to make column B in Excel of type "text" so that you can order by that column & have them come out in a nice logical order, that is, without all the numbers coming first. You also have to add the Sldworks 2004 Type Library in Excel VBA.
Depending on how many files you have, this can take a while to run.
Sub FindConfigs() ' Dim i As Long Dim j As Long Dim k As Long
Dim Begin Dim fs As Object Dim swApp As SldWorks.SldWorks Dim vConfName As Variant Dim strAllFiles() As String Dim strSelFiles() As String Dim lngConfigCount As Long Set swApp = CreateObject("SldWorks.Application") ReDim strAllFiles(256) Set fs = Application.FileSearch With fs .LookIn = "N:\ENGINEERING\00 - VAULT\Solidworks Files\" .SearchSubFolders = True .Filename = "*.sldprt;*.sldasm;*.prt;*.asm" If .Execute() > 0 Then For i = 1 To .FoundFiles.Count If i > UBound(strAllFiles) Then ReDim Preserve strAllFiles(UBound(strAllFiles) + 256) End If strAllFiles(i) = .FoundFiles(i) Next i Else MsgBox "There were no files found." End If End With j = 1 For i = 1 To UBound(strAllFiles) Debug.Print strAllFiles(i) If InStr(strAllFiles(i), "~$") = 0 Then 'excludes "those" files ReDim Preserve strSelFiles(j) strSelFiles(j) = strAllFiles(i) j = j + 1 End If Next i k = 2 'leaves the 1st row empty for titles in Excel Spreadsheet For i = 1 To UBound(strSelFiles) lngConfigCount = swApp.GetConfigurationCount(strSelFiles(i)) If lngConfigCount > 1 Then 'ignore files with only one configuration vConfName = swApp.GetConfigurationNames(strSelFiles(i)) For j = 0 To UBound(vConfName) If vConfName(j) "Default" Then 'don't list "Default" configurations Range("A" & k).Value = strSelFiles(i) Range("B" & k).Value = vConfName(j) k = k + 1 End If Next j End If Next i End Sub
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.