LocateFile Method

Microsoft FrontPage Visual Basic

Returns the specified WebFile object.

expression.LocateFile(FileUrl)

expression    An expression that returns a WebEx object.

FileUrl   Required String. Default value is the file portion of the URL.

Example

This example locates a file in the root directory of the Web site and puts the file in edit mode.

Note  You must have a Web site open and a file called "Zinfandel.htm," or you may substitute a file of your choice.

Private Sub LocateAFile()
    Dim myFile As WebFile

    Set myFile = Webs(0).LocateFile("Zinfandel.htm")
    myFile.Edit
End Sub

In most cases, you would probably use the entire URL for the String argument of the LocateFile method— for example, if you wanted to locate the file First_Qtr.htm in C:/My Documents/My Web Sites/Rogue Cellars/Inventory/First_Qtr.htm. Any time a folder exists in a level deeper than the root directory of the Web site, use the entire URL as shown in the following example.

Private Sub GetFile()
    Dim myFile As String
    Dim myFileFound As WebFile

    myFile = _
        "C:/My Documents/My Web Sites/Rogue Cellars/Inventory/First_Qtr.htm"

    Set myFileFound = Webs(0).LocateFile(myFile)
End Sub

However, there is a shortcut. For example, if you want to locate a file in an images folder that resides in the root directory of the Web site, you can use a relative address by using a forward slash followed by the subfolder and file name as shown in the following statement.

Set myFileFound = Webs(0).LocateFile("images/JPG/myJPGFileList.htm")

Note  You cannot substitute a backslash in a relative address.