FrontPage VBA教程:SubTree属性



expression  必选。返回 NavigationNode对象的表达式。


下列示例提示用户输入当前站点中的导航节点的名称,并返回该特定节点的子树。如果找到该节点,则将其label属性值添加到一个 String 类型的值中,其中包含父节点的子树中所有节点的名称。存储在变量 strSubNodes 中的这个 String 值会显示给用户。如果站点中没有找到该节点,则向用户显示一条消息。

Sub DisplaySubTree()
'Returns the subtree of a given node
    Dim objApp As FrontPage.Application
    Dim objNavNode As NavigationNode
    Dim objNavNodes As NavigationNodes
    Dim objSubTree As NavigationNodes
    Dim objSubNode As NavigationNode
    Dim strAns As String      'User input
    Dim blnFound As Boolean   'Boolean found flag
    Dim intCount As Integer   'Integer counter
    Dim strSubNodes As String 'Names of all sub nodes
    blnFound = False
    intCount = 0
    Set objApp = FrontPage.Application
    'Create a reference to the NavigationNodes collection
    Set objNavNodes = objApp.ActiveWeb.AllNavigationNodes
    'Prompt the user to enter the name of the node
    strAns = InputBox("Enter the name of the node for which " & _
                       " you want to view the subtree.")
    'While the node is not found and there are more nodes in the tree
    Do While (Not blnFound = True) And (intCount <= objNavNodes.Count - 1)
        'Compare user input with node label
        If Trim(strAns) = objNavNodes.Item(intCount).Label Then
            'If found, return node
            Set objNavNode = objNavNodes.Item(intCount)
            'Set found flag to true
            blnFound = True
            'Otherwise increase counter, keep checking
            intCount = intCount + 1
        End If
    If blnFound = True Then
       Set objSubTree = objNavNode.SubTree
       For Each objSubNode In objSubTree
           'If the string is empty or has not yet been set
           If strSubNodes = "" Then
               strSubNodes = strSubNodes & objSubNode.Label
               'otherwise add next node lable to string
               strSubNodes = strSubNodes & ", " & vbCr & objSubNode.Label
           End If
       Next objSubNode
       'Display names of all nodes in subtree
       MsgBox "The nodes found in the subtree of " & objNavNode.Label & " are: " _
              & vbCr & vbCr & strSubNodes & "."
       'If not found, display message to user
       MsgBox "The navigation node " & strAns & " was not found."
    End If
End Sub

上页:FrontPage VBA教程:styleSheets属性 下页:FrontPage VBA教程:SubViewMode属性

FrontPage VBA教程:SubTree属性

FrontPage VBA教程:SubViewMode属性 FrontPage VBA教程:System属性
FrontPage VBA教程:Template属性 FrontPage VBA教程:ThemeProperties属性
FrontPage VBA教程:Themes属性 FrontPage VBA教程:Title属性
FrontPage VBA教程:Type属性 FrontPage VBA教程:URL属性
FrontPage VBA教程:UserName属性 FrontPage VBA教程:VBE属性
FrontPage VBA教程:Version属性 FrontPage VBA教程:VerticalResolution属性
FrontPage VBA教程:ViewMode属性 FrontPage VBA教程:ViewModeEx属性
FrontPage VBA教程:Visible属性 FrontPage VBA教程:vlinkColor属性
FrontPage VBA教程:Web属性 FrontPage VBA教程:webbots属性
FrontPage VBA教程:Webs属性 FrontPage VBA教程:WebWindows属性
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号