Public Function SplitFileName(strDocumentNameAndPath As String, strReturn As String) As String
On Error GoTo errorhandler
Dim oFSO As New FileSystemObject
Dim oFile As File
If oFSO.FileExists(strDocumentNameAndPath) Then
Set oFile = oFSO.GetFile(strDocumentNameAndPath)
Select Case UCase$(strReturn)
Case "FILE"
SplitFileName = oFile.Name
Case "PATH"
SplitFileName = oFSO.GetParentFolderName(oFile.Path) & "\"
End Select
Set oFile = Nothing
End If
Set oFSO = Nothing
' Exit = No errors
Exit Function
errorhandler:
Set oFSO = Nothing
SplitFileName = vbNullString
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.