Returning an Object from a Collection

Microsoft FrontPage Visual Basic

Returning an Object from a Collection

The Item property returns a single object from a collection. The following statements set the fileOne variable to a WebFile object that represents the first file in the Files collection.

Note  All collections in the Microsoft FrontPage Web and Page object models are zero-based, so you access the first item in the collection by using a zero.

    Dim fileOne As WebFile

Set fileOne = ActiveWeb.RootFolder.Files.Item(0)
  

The Item property is the default property for most collections, so you can omit the Item keyword as shown in the following statement.

    Set fileOne = ActiveWeb.RootFolder.Files(0)
  

Named objects

Although you can usually specify an integer value with the Item property, it may be more convenient to return an object by name. The following example edits a file named Web Sales.htm in the active Web page.

    ActiveWeb.RootFolder.Files("Web Sales.htm").Edit