This example locates a folder in the root directory of a web.
Note You must have a web open for all of these examples.
Private Sub LocateAFolder()
Dim myFolderFound As WebFolder
Set myFolderFound = Webs(0).LocateFolder("images")
End Sub
In most cases, you would probably use the entire URL for the String argument of the LocateFolder method. For example, a folder may be several levels deep in the folder hierarchy, such as C:/My Documents/My Webs/Rogue Cellars/Inventory/First_Quarter—and you want to locate First_Quarter. Anytime a folder exists in a level deeper than the root directory of the web, use the entire URL as shown in the following example.
Private Sub GetFolder()
Dim myFolder As String
Dim myFolderFound As WebFolder
myFolder = _
"C:/My Documents/My Webs/Rogue Cellars/Inventory/First_Quarter"
Set myFolderFound = _
Webs(0).LocateFolder(myFolder)
End Sub
However, there is a shortcut. For example, if you want to locate an images folder that resides in the root directory of the web, you can use a web relative address by using a forward slash followed by the subfolder name as shown in the following statement.
Set myFolderFound = Webs(0).LocateFolder("images/JPG")
Note You cannot substitute a backslash in a web relative address.