Hello
I found several posts in various forums but I can't do it...
The following macro, derived from several pieces of code, exports the Description, Number and Reference properties of SLDPRT files to an excel.
However, the macro doesn't go in the subfolders and I can't seem to go there!
Would someone be kind enough to help me complete the code?
Thanks in advance,
Dim Part As SldWorks.ModelDoc2
Dim a As Object
Dim fs As Object
Dim Currentpath As String
Dim Subfolder As Object
Function SelectFolder(Optional Title As String, Optional TopFolder As String) As String
Dim objShell As New Shell32.Shell
Dim objFolder As Shell32.Folder
'If you use 16384 instead of 1 on the next line, files are also displayed
Set objFolder = objShell.BrowseForFolder(0, Title, 1, TopFolder)
If Not objFolder Is Nothing Then
SelectFolder = objFolder.Items.Item.Path
End If
End Function
Sub main()
Set swApp = Application.SldWorks
Set fs = CreateObject("Scripting.FileSystemObject")
filename = InputBox("filename: ")
filename = filename & ".csv"
Set a = fs. CreateTextFile("C:\Users\***********\Desktop\" & filename, True)
Visibility = swApp.DocumentVisible(False, swDocPART)
a.writeline ("Number" & ";" & "Description" & ";" & "Reference")
'Choice folder + .sldprt file recovery
Currentpath = SelectFolder("Select Folder", "")
If Currentpath = "" Then
End If
Currentpath = Currentpath & "\"
FileName = Dir(Currentpath & "*.sldprt")
End of phase
Do While FileName <> ""
Set Part = swApp.OpenDoc(Currentpath & FileName, swDocPART)
Description = Part.GetCustomInfoValue("", "Description")
Number = Part.GetCustomInfoValue("", "Number")
Reference = Part.GetCustomInfoValue("", "reference")
a.writeline (Number&";" & Description &";" & Reference)
swApp.CloseDoc FileName
FileName = Dir
Loop
Visibility = swApp.DocumentVisible(True, swDocPART)
End Sub