Author: Calvin Smith
http://www.CalvinSmithSoftware.com/codedisk/sneakpeek.htm

The following code demonstrates how a developer can
programmatically determine if a filename is bad.

'**********************************************************
'************ Code provided by CodeDisk II. ***************
'**********************************************************


Function CheckForBadFilename(strAnyFileName As String) As String

On Error GoTo ErrorHandling_Err

    ' ----------------------------------------------------------------------
    ' Purpose: Check your filename for accuracy prior to processing it.
    '
    ' Accepts: Any passed in filename
    '
    ' Returns: The bad character that it found, if any
    '
    ' Example usage: strRetVal = CheckForBadFilename("CalvinTest.>doc")
    '
    ' NOTE: Possible Illegal Filename Characters: ? [ ] / \ = + < > : ; ,
    ' ----------------------------------------------------------------------

 CheckForBadFilename = IIf(InStr(strAnyFileName, ">"), "Please note: > found", _
			IIf(InStr(strAnyFileName, "<"), "Please note: < found", _
			IIf(InStr(strAnyFileName, "?"), "Please note: ? found", _
			IIf(InStr(strAnyFileName, "["), "Please note: [ found", _
			IIf(InStr(strAnyFileName, "]"), "Please note: ] found", _
			IIf(InStr(strAnyFileName, "/"), "Please note: / found", _
			IIf(InStr(strAnyFileName, "\"), "Please note: \ found", _
			IIf(InStr(strAnyFileName, "="), "Please note: = found", _
			IIf(InStr(strAnyFileName, "+"), "Please note: + found", _
			IIf(InStr(strAnyFileName, ":"), "Please note: : found", _
			IIf(InStr(strAnyFileName, ","), "Please note: , found", _
			"Please note: filename okay")))))))))))

ErrorHandling_Err:
    If Err Then
        'Trap your error(s) here, if any!
    End If
End Function