Returns a String that represents a relative URL for the String specified in the URL parameter, using the URLBase parameter as the starting point. If the URL is already relative to the URLBase parameter, the URL is returned unchanged. For more information about absolute and relative URLs, refer to Understanding Absolute and Relative URL Addressing.
expression.MakeRel(UrlBase, Url)
expression An expression that returns an Application object.
UrlBase Required Variant. A base URL. Can be a string or a WebEx, WebFolder, WebFile, NavigationNode, or IHTMLDocument2 object.
Url Required String. A string that contains the entire URL. This can be any URL for a Web site, such as "http://web server/folder"
or "file://file system/folder"
for disk-based Web sites.
Example
This example changes an absolute URL to a relative URL, adds a hyperlink to the active document using the relative URL, and then saves the changes to the document.
Note To run this example, you must have a Web site called "C:\My Documents\My Web Sites\Rogue Cellars." You must also have two files, one called "Zinfandel.htm" and the other called "index.htm," which has an absolute URL (the default state). Or, you may substitute an alternative Web site URL and file names.
Private Sub MakeURLRelative()
Dim myFile As WebFile
Dim myFile2 As WebFile
Dim myBaseURL As WebEx
Dim myDoc As FPHTMLDocument
Dim myRelAddress As String
Dim myRelAddress2 As String
Set myBaseURL = Webs.Open("C:\My Documents\My Web Sites\Rogue Cellars")
Set myFile = myBaseURL.RootFolder.Files("Zinfandel.htm")
Set myFile2 = myBaseURL.RootFolder.Files("index.htm")
Set myDoc = myFile.Edit(fpPageViewNormal).Document
myRelAddress = MakeRel(myBaseURL, myFile2.Url)
myRelAddress2 = """" & myRelAddress & """"
Call myDoc.body.insertAdjacentHTML("BeforeEnd", "<a href=" _
& myRelAddress2 & ">" & myRelAddress & "</a>")
ActivePageWindow.Save
End Sub