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 active page window.
Note To run this example, you must have a web called "C:\My Documents\My Webs\Rogue Cellars" (for a server running on Microsoft Windows) or "C:\WINNT\Profiles\logon alias\Personal\My Webs\Rogue Cellars" (for a server running on Windows NT). 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 URL and substitute alternative file names.
Private Sub MakeURLRelative()
Dim myFile As WebFile
Dim myFile2 As WebFile
Dim myBaseURL As Web
Dim myDoc As FPHTMLDocument
Dim myRelAddress As String
Dim myRelAddress2 As String
Set myBaseURL = Webs.Open("C:\My Documents\My Webs\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