Function MakeAbsolute(strLinkURL, strCurrentURL) 'Returns an absolute link URL. The strLinkURL can be 'any type, but the strCurrentURL must be absolute. Dim strCurrentFolder, strMakeAbsolute, strRoot, strDocument, strPart1, strPart2, lngDots strRoot = "" 'Initialize empty because we'll test later to see if it's been set. 'There are 3 link types: absolute, root, and relative. 'Handle the easiest case: Is strLinkURL already absolute? If Left(strLinkURL, 7) = "http://" Then MakeAbsolute = strLinkURL Exit Function End If 'Now we only have 2 remaining link types: root and relative 'There are 3 current URL types: document, folder, and root. 'Take the strCurrentURL and generate a current folder and root (both with no trailing slash) strCurrentFolder = Split(strCurrentURL, "?")(0) 'Remove any GET arguments If InStr(8, strCurrentFolder, "/") <> 0 Then 'strCurrentFolder is a document or a folder. Crop to the last slash to make it a folder. strCurrentFolder = Left(strCurrentFolder, InStrRev(strCurrentFolder, "/") - 1) If InStr(8, strCurrentFolder, "/") = 0 Then strRoot = strCurrentFolder Else strRoot = Left(strCurrentFolder, InStr(8, strCurrentFolder, "/") - 1) End If Else 'strCurrentFolder must be a root (http://nowhere.com/). Be sure it has no trailing slash. If Right(strCurrentFolder, 1) = "/" Then strCurrentFolder = Left(strCurrentFolder, Len(strCurrentFolder) - 1) strRoot = strCurrentFolder End If End If 'Handle the next easiest link type: Is strLinkURL a root reference? If Left(strLinkURL, 1) = "/" Then MakeAbsolute = strRoot & strLinkURL Exit Function End If 'Now the only link type we have is relative. 'Now handle the relative link. strMakeAbsolute = strCurrentFolder & "/" & strLinkURL 'Remove any double dots Do While InStr(strMakeAbsolute, "/../") <> 0 'http://machine/a/b/../index.html lngDots = InStr(strMakeAbsolute, "/../") strPart1 = Left(strMakeAbsolute, lngDots - 1) 'http://machine/a/b strPart2 = Mid(strMakeAbsolute, lngDots + 3) '/index.html strPart1 = Left(strPart1, InStrRev(strPart1, "/") - 1) 'http://machine/a strMakeAbsolute = strPart1 & strPart2 'http://machine/a/index.html Loop MakeAbsolute = strMakeAbsolute End Function