Showing posts with label Show file name picker dialog box using VBA. Show all posts
Showing posts with label Show file name picker dialog box using VBA. Show all posts

Monday, August 22, 2011

Show file name picker dialog box using VBA

If you want open the file picker dialog box and save the full path of file in a variable . Try this macro  -




Sub choose_file()

    Dim flname As String
    Dim fd As FileDialog, fl As Variant
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    With fd
        .AllowMultiSelect = False
        .Title = "Please choose the file"
        .Filters.Add "Excel Files", "*.xls*", 1
        .Show
    End With
    
    For Each fl In fd.SelectedItems
        flname = fl
    Next
    
    If flname = "" Then
        MsgBox "File Not selected", vbInformation, "Note:"
    Else
        MsgBox flname
    End If


End Sub

Import data from SQL

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