Dear All,
I am trying to use the following code to open first an Excel file and then a CSV file. the Excel filter is fine. However I cannot get the filter to show only CSV Files (see the line in bold which ought to restrict the view to just CSV files - bu gives me Excel files). Thanks
Kaps
thanks
Kaps
I am trying to use the following code to open first an Excel file and then a CSV file. the Excel filter is fine. However I cannot get the filter to show only CSV Files (see the line in bold which ought to restrict the view to just CSV files - bu gives me Excel files). Thanks
Kaps
Rich (BB code):
Dim file_name As String
Dim FilterIndex As Integer
Dim filter As String
Dim fd1 As FileDialog
Dim fd2 As FileDialog
'open the credit card file
Set fd1 = Application.FileDialog(msoFileDialogFilePicker)
With fd1
.AllowMultiSelect = False
' .InitialFileName = local_path
.Title = "Please select Bank file"
.Filters.Add "Excel files", "*.xls; *.xlsx", 1
If .Show = -1 Then file_name = .SelectedItems(1)
End With
If Len(file_name) > 0 Then
'open the workbook
Workbooks.Open file_name
Set Credit_card_workbook = ActiveWorkbook
End If
'open the Sage CSV file
Set fd2 = Application.FileDialog(msoFileDialogFilePicker)
With fd2
.AllowMultiSelect = False
' .InitialFileName = local_path
.Title = "Please select Sage file"
.Filters.Add "text files| ", "*.csv"
If .Show = -1 Then file_name = .SelectedItems(1)
End With
If Len(file_name) > 0 Then
'open the workbook
Workbooks.Open file_name
Set Sage_Input_workbook = ActiveWorkbook
End If
Kaps