G
Guest
I'm using the code found in www.mvps.org/access/api/api0001.htm. It works
great, but I'm trying to more gracefully handle the situation when the user
clicks Cancel in the dialog box. Currently, when you click cancel you get an
"Action or method requires a file name argument" message.
Ideally, I'd like to suppress this message and exit the function - I was
kind of thinking this would do it, but no luck - it's not trapping that error.
Public Function Get_FileNamexls() As String
Dim strFilter As String
Dim lngFlags As Long
On Error GoTo Err_Get_FileNamexls
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.xls")
Get_FileNamexls = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Select File To Import/Export")
Exit_Get_FileNamexls:
Exit Function
Err_Get_FileNamexls:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Get_FileNamexls
End Function
How can I more gracefully handle the Cancel button click?
great, but I'm trying to more gracefully handle the situation when the user
clicks Cancel in the dialog box. Currently, when you click cancel you get an
"Action or method requires a file name argument" message.
Ideally, I'd like to suppress this message and exit the function - I was
kind of thinking this would do it, but no luck - it's not trapping that error.
Public Function Get_FileNamexls() As String
Dim strFilter As String
Dim lngFlags As Long
On Error GoTo Err_Get_FileNamexls
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.xls")
Get_FileNamexls = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Select File To Import/Export")
Exit_Get_FileNamexls:
Exit Function
Err_Get_FileNamexls:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Get_FileNamexls
End Function
How can I more gracefully handle the Cancel button click?