Brings up a dialog box that asks the user for a filename. : CSV « File Path « VBA / Excel / Access / Word






Brings up a dialog box that asks the user for a filename.

 
  Sub GetImportFileName()
      Dim Finfo As String
      Dim FilterIndex As Integer
      Dim Title As String
      Dim FileName As Variant
      FInfo = "Text Files (*.txt),*.txt," & _
              "Lotus Files (*.prn),*.prn," & _
              "Comma Separated Files (*.csv),*.csv," & _
              "ASCII Files (*.asc),*.asc," & _
              "All Files (*.*),*.*"
  '   Display *.* by default
      FilterIndex = 5
      Title = "Select a File to Import"
      FileName = Application.GetOpenFilename(FInfo,FilterIndex, Title)
      If FileName = False Then
          MsgBox "No file was selected."
      Else
          MsgBox "You selected " & FileName
      End If
  End Sub

 








Related examples in the same category

1.Query text file
2.Saves the active worksheet in the workbook named MyWorkbook.xls as a comma-delimited text file named test.csv:
3.Split demonstration
4.Create text file based database
5.Export active worksheet to CSV file