SharePointURL2Path + Path2SharePointURL

Converts SharePoint URL to regular folder path and the other way, giving the root URL for SharePoint like "http://sharepoint.website.com/sites/gitpa/pmo/default.aspx?RootFolder="

CodeFunctionName
What is this?

Public

Tested

Original Work
Function SharePointURL2Path(URL2) ' Converts SharePoint url into regular folder (remote on intranet)
' Basically replacing %2f to \, %20 to space and %2d to -
SharePointURL2Path = "N/A"
StartHere = "?RootFolder="
remm = InStr(1, URL2, "//")
If remm > 0 Then
remmo = InStr(remm + 2, URL2, "/")
domain = Mid(URL2, remm + 2, remmo - remm - 2)
folll = InStr(1, URL2, StartHere, vbTextCompare)
NewURL = Mid(URL2, folll + Len(StartHere))
SharePointURL2Path = "\\" & domain & Replace(NewURL, "%2f", "\", , , vbTextCompare)
SharePointURL2Path = Replace(SharePointURL2Path, "%20", " ", , , vbTextCompare)
SharePointURL2Path = Replace(SharePointURL2Path, "%2d", "-", , , vbTextCompare)
End If
End Function
Function Path2SharePointURL(Path2, ShPoRoot) ' convert remote folder path (intranet) into regular sharepoint url
' Basically replacing \ to %2f (or /), space to %20 and - to %2d
' ShPoRoot is the root folder for SharePoint on the intranet
' Like "http://sharepoint.website.com/sites/gitpa/pmo/default.aspx?RootFolder="
' Note that ?RootFolder at end is needed
Path2SharePointURL = "Not yet ready"
StartHere = ShPoRoot ' "http://globalwss.ea.com/sites/gitpa/pmo/default.aspx?RootFolder="
If Left(Path2, 2) = "\\" Then
sta = InStr(3, Path2, "\")
Path2SharePointURL = StartHere & Mid(Path2, sta)
Path2SharePointURL = Replace(Path2SharePointURL, "\", "%2f", , , vbTextCompare)
Path2SharePointURL = Replace(Path2SharePointURL, " ", "%20", , , vbTextCompare)
Path2SharePointURL = Replace(Path2SharePointURL, "-", "%2d", , , vbTextCompare)
End If
End Function

URL2
Or
Path2, ShPoRoot

Views 4,471

Downloads 1,378

CodeID
DB ID