Browse Folder

Option to select a folder in a convenient window using the Excel API in Solidworks VBA. I’ll leave this here.
excelLib.jpg

Dim xlApp As Excel.Application
'Dim xlWB    As Excel.Workbook
Dim FolderPath As String

Sub Main()
    ' Create a hidden instance of Excel
    On Error Resume Next
    Set xlApp = New Excel.Application
    xlApp.Visible = False
    xlApp.DisplayAlerts = False
    'open the folder selection dialog box
        With xlApp.FileDialog(4) 'msoFileDialogFolderPicker
            .Title = "Select Folder"
            .AllowMultiSelect = False
            .InitialView = msoFileDialogViewList
            'Make different settings here
            If .Show = 0 Then
                FolderPath = "" 'folder not selected 
            Else
                On Error Resume Next
                Err.Clear
                If Err.Number <> 0 Then
                    FolderPath = "" 'folder selected error
                End If
                FolderPath = .SelectedItems(1)
            End If
        End With
    If FolderPath <> "" Then
        MsgBox "folder selected: " & FolderPath, vbInformation
    Else
        MsgBox "folder not selected.", vbInformation
    End If
    ' Closing an app of Excel
   ' xlWB.Close
    'Set xlWB = Nothing
    xlApp.Quit
    Set xlApp = Nothing
End Sub