Monday, August 22, 2011

Show folder name picker dialog box using VBA

If you want open the folder picker dialog box and then save the path of the folder for further use. Try this macro

Sub choose_folder()

    Dim fldname As String
    Dim fd As FileDialog, fl As Variant
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
    With fd
        .AllowMultiSelect = False
        .Title = "Please select the folder"
    End With
    For Each fl In fd.SelectedItems
        fldname = fl
    If fldname = "" Then
        MsgBox "Folder Not selected", vbInformation, "Note:"
        MsgBox fldname & "\"
    End If
End Sub

No comments:

Post a Comment

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...