Getting a "Run-time error '91'" when running this code. Thoughts?
Sub OpenNewCSV()
'Dim fDialog As FileDialog, Result As Integer
'Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
Dim fDialog As FileDialog, Result As Integer
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
'Optional FileDialog Properties
fDialog.AllowMultiSelect = False
fDialog.Title = "Select a file"
fDialog.InitialFileName = "C:\"
'Optional: Add filters
fDialog.Filters.Clear
fDialog.Filters.Add "Excel files", "*.csv"
fDialog.Filters.Add "All files", "*.*"
'Show the dialog. -1 means success!
If fDialog.Show = -1 Then
Debug.Print fDialog.SelectedItems(1)
End If
'Result: C:\somefile.xlsx
End Sub
Sub OpenNewCSV()
'Dim fDialog As FileDialog, Result As Integer
'Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
Dim fDialog As FileDialog, Result As Integer
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
'Optional FileDialog Properties
fDialog.AllowMultiSelect = False
fDialog.Title = "Select a file"
fDialog.InitialFileName = "C:\"
'Optional: Add filters
fDialog.Filters.Clear
fDialog.Filters.Add "Excel files", "*.csv"
fDialog.Filters.Add "All files", "*.*"
'Show the dialog. -1 means success!
If fDialog.Show = -1 Then
Debug.Print fDialog.SelectedItems(1)
End If
'Result: C:\somefile.xlsx
End Sub