Previous in Contents Next in Contents

Creating and Accessing IStartPage Interface Objects

You create an IStartPage interface object by calling the Add method. You can access a specific IStartPage interface object by calling the Item roperty. Because IStartPages is a collection, you can access all IStartPage interface objects using a for each loop, as in the following example, where objStartPage is the name you give to the IStartPage interface object:

Option Explicit 
On Error Resume Next 

Dim objSearchAdmin, objBuildCatalog, objStartPage 

Set objSearchAdmin   = CreateObject("Search.SearchAdmin.1") 
Set objBuildCatalog    = _
  objSearchAdmin.BuildServer.BuildCatalogs("KMSampleCatalog1")

'Add www.Microsoft.com to the StartPages
objStartPage = objBuildCatalog.objStartPages.Add _
  "http://www.microsoft.com"

'Make it a Web crawl that follows site rules only 
objStartPage.FollowDirectories = False
objStartPage.EnumerationDepth  = -1
objStartPage.HostDepth         = -1

For Each objBuildCatalog IN objSearchAdmin.BuildServer.BuildCatalogs
  Wscript.Echo objBuildCatalog.Name & " starts crawling at address(es):"

  If objStartPage.FollowDirectories Then 
    If objStartPage.EnumerationDepth = -1 Then
      Wscript.Echo "  " & objStartPage.URL _
        & " and performs a file crawl through all subdirectories"
    ElseIf objStartPage.EnumerationDepth = 0 Then
      Wscript.Echo "  " & objStartPage.URL _
        & " and performs a file crawl in only the starting address"
    ElseIf objStartPage.EnumerationDepth > 0 Then
      Wscript.Echo "  " & objStartPage.URL _
        & " and performs a file crawl through " _
        & objStartPage.EnumerationDepth _
        & " subdirectories deep"
    End If
  Else
    If objStartPage.HostDepth = -1 AND _
       objStartPage.EnumerationDepth = -1 Then
      Wscript.Echo "  " & objStartPage.URL _
        & " and performs a Web link crawl using site rules only"
    ElseIf objStartPage.EnumerationDepth = 0 Then
      If objStartPage.HostDepth = 0 Then
        Wscript.Echo "  " & objStartPage.URL _
          & " and performs a Web link crawl only _
              on this page at this site"
      ElseIf objStartPage.HostDepth > 0 Then
        Wscript.Echo "  " & objStartPage.URL _
          & " and performs a Web link crawl only _
              on this page with up to " _
          & objStartPage.HostDepth & " site hops"
      End If
    ElseIf objStartPage.EnumerationDepth > 0 Then
      If objStartPage.HostDepth = 0 Then
        Wscript.Echo "  " & objStartPage.URL _
          & " and performs a Web link crawl with up to " _
          & objStartPage.EnumerationDepth & " page hops _
            only at this site"
      ElseIf objStartPage.HostDepth > 0 Then
        Wscript.Echo "  " & objStartPage.URL _
          & " and performs a Web link crawl with up to " _
          & objStartPage.EnumerationDepth & " page hops with up to " _
          & objStartPage.HostDepth & " site hops"
      End If
    End If

    Wscript.Echo "  (HostDepth= " & objStartPage.HostDepth _
      & ", EnumerationDepth= " & objStartPage.EnumerationDepth & ")"

    Wscript.Echo ""
  End If
Next

'Release objects 
Set objStartPage    = Nothing 
Set objBuildCatalog = Nothing 
Set objSearchAdmin  = Nothing 
 

© 1997-2000 Microsoft Corporation. All rights reserved.