Private Sub btnBrowse_Click() Application.FileDialog(msoFileDialogFolderPicker).Show = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems.Item(1) End Sub Private Sub btnRun_Click() Dim FSO As Scripting.FileSystemObject Dim sFolder As Scripting.Folder 'Clear Excel Data Call clearxData 'Title Names Range("A2").Value = "Sr.
#Solidworks 2016 serial 9000 code#
#Copy Below Code inside horizontal lines into your Excel Macro > Sheet1(Sheet1) # Now Go to your Sheet1 code by double clicking on it Set swApp = CreateObject("SldWorks.Application") vVerStr = swApp.VersionHistory(swFilePath) varVerLast = vVerStr(UBound(vVerStr)) 'Get Last Saved Version varSwVer = Split(varVerLast, "[") Select Case varSwVer(0) Case 8001 To 9000 swFileVersion = "SOLIDWORKS 2016" Case 7001 To 8000 swFileVersion = "SOLIDWORKS 2015" Case 6001 To 7000 swFileVersion = "SOLIDWORKS 2014" Case 5001 To 6000 swFileVersion = "SOLIDWORKS 2013" Case 4701 To 5000 swFileVersion = "SOLIDWORKS 2012" Case 4401 To 4700 swFileVersion = "SOLIDWORKS 2011" Case 4101 To 4400 swFileVersion = "SOLIDWORKS 2010" Case Else swFileVersion = "Out of Range" End Select End Sub Sub FilesInsideFolder(myFolder As Scripting.Folder, includeSubFolder As Boolean) ' Starting Row r = Cells(Rows.Count, "A").End(xlUp).Row + 1 On Error Resume Next For Each sFile In myFolder.Files Cells(r, 1).Formula = r - 2 'Serial Number Cells(r, 2).Formula = sFile.Name ' File Name with Extension Cells(r, 3).Formula = sFile.Path ' File Path swFilePath = sFile.Path 'Call checkSWFileVersion to get SW Version Name and Number Call checkSWFileVersion(swFilePath) Cells(r, 4).Formula = swFileVersion 'Sw File Version Name Cells(r, 5).Formula = varSwVer(0) ' Version Number r = r + 1 Next sFile If includeSubFolder Then For Each subFolder In myFolder.SubFolders FilesInsideFolder subFolder, True Next subFolder End If End Sub Sub clearxData() Range("A3").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Range(Selection.Address).ClearContents End SubĤ. #Copy Below Code inside horizontal lines into your Excel Macro > Module1 #ĭim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim vVerStr As Variant Dim varVerLast As Variant Dim varSwVer As Variant Dim swFilePath As String Dim swFileVersion As String Dim subFolder As Scripting.Folder Dim sFile As Scripting.File Dim sPath As String Dim r As Long Dim includeSubFolder As Boolean Sub checkSWFileVersion(swFilePath) 'This code is for Reference only from 'Need to add 'sldworks SWXXXX Type Library' reference from Tools > References. Add ‘Microsoft Scripting Runtime’ reference to this VBA Project from Tools > References…Īlso Check that ‘sldworks SWXXXX Type Library’ reference is also added in this VBA Project.ģ. Go to your Module1 code by double clicking on it Look at the Excel File Sheet 1 Layout & understand VBA code in this article accordinglyĢ. So, in continuation to the article Check Last Saved Version of SolidWorks File – Rev0 Here we will go to next step.ġ.