GetSon + GetPapa (with _URL and _Sep versions)

Gets that parent folder name giving a full path, or gets the child folder, Can be used in PC or Mac, also a version for URL papa and Son
GetPapa, GetPapa_URL, GetPapa_Sep, GetSon, GetSon_uRL, GetSon_Sep

Public
Tested
My Own Work
' Gets parent of a file/folder or the child, Can be used in PC or Mac
' GetPapa, GetPapa_URL, GetPapa_Sep, GetSon, GetSon_uRL, GetSon_Sep
Function GetSon(FullPath)
 GetSon = GetSon_Sep(FullPath)
End Function
Function GetPapa(Optional FullPath= "This")
 If FullPath= "This" Then FullPath= Thisworkbook.Path
 GetPapa = GetPapa_Sep(FullPath)
End Function
Function GetSon_URL(FullPath)
 GetSon_URL = GetSon_Sep(FullPath, "/")
End Function
Function GetPapa_URL(FullPath)
 GetPapa_URL = GetPapa_Sep(FullPath, "/")
End Function
Function GetSon_Sep(FullPath, Optional Separator = "\")
 ' Reads the son of a string based on certain separator, default is \ for file path
 If Application.OperatingSystem Like "*Mac*" And Separator = "\" Then Seperater = ":"
 lastslash = InStrRev(FullPath, Separator)
 GetSon_Sep = Mid(FullPath, lastslash + 1)
End Function
Function GetPapa_Sep(FullPath, Optional Separator = "\")
 ' Reads the father of a string based on certain separator, default is \ for file path
 If Application.OperatingSystem Like "*Mac*" And Separator = "\" Then Seperater = ":"
 lastslash = InStrRev(FullPath, Separator)
 GetPapa_Sep = FullPath
 If lastslash > 0 Then GetPapa_Sep = Left(FullPath, lastslash - 1)
End Function

FullPath
or
FullPath, Optional Separator

Views 2080 Downloads 971

VBA-Excel Texts + Strings
ANmarAmdeen
629
Revisions

v2.0