Public Function fncFindFile(ByRef strPath As String, Optional ByRef strType As String) As Boolean
On Error GoTo ERRHANDLE
Select Case strType
Case "csv"
strType = "CSV (Comma Delimited) (*.csv)" + Chr$(0) + "*.csv" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
Case "xls"
strType = "Microsoft Excel Workbook (*.xls)" + Chr$(0) + "*.xls" + Chr$(0) + "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
Case "txt"
strType = "Text Files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
Case Else
strType = "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
End Select
If IsNull(strPath) Then strPath = "V:\DMT\"
If strPath = "" Then strPath = "V:\DMT\"
Dim OFName As OPENFILENAME
OFName.lStructSize = Len(OFName)
'Set the parent window
'OFName.hwndOwner = Me.hwnd
'Set the application's instance
'OFName.hInstance = App.hInstance
'Select a filter
OFName.lpstrFilter = strType
'create a buffer for the file
OFName.lpstrFile = Space$(254)
'set the maximum length of a returned file
OFName.nMaxFile = 255
'Create a buffer for the file title
OFName.lpstrFileTitle = Space$(254)
'Set the maximum length of a returned file title
OFName.nMaxFileTitle = 255
'Set the initial directory
OFName.lpstrInitialDir = strPath
'Set the title
OFName.lpstrTitle = "Import Excel File - New London Aircode"
'No flags
OFName.flags = 0
'Show the 'Open File'-dialog
If GetOpenFileName(OFName) Then
strPath = Trim$(OFName.lpstrFile)
fncFindFile = True
Else
fncFindFile = False
'MsgBox "Cancel was pressed"
End If
ERREXIT:
Exit Function
ERRHANDLE:
MsgBox Err.Description, vbOKOnly, "Procedure: fncFindFile"
fncFindFile = False
Resume ERREXIT
End Function