<?xml encoding=”UTF-8″>By Adam Nagy
If you want to find out which items in the browser are selected, then you can simply iterate through all the items in the tree recursively and check each node’s Selected property.
The following VBA sample shows this in case of a drawing document:
Function GetSelectedItems(nodes As BrowserNodesEnumerator) As String
Dim node As BrowserNode
For Each node In nodes
If node.Selected Then
GetSelectedItems = GetSelectedItems _
+ vbCrLf + node.BrowserNodeDefinition.Label
End If
GetSelectedItems = GetSelectedItems _
+ GetSelectedItems(node.BrowserNodes)
Next
End Function
Sub GetSelectedItemsInBrowser()
Dim doc As Document
Set doc = ThisApplication.ActiveDocument
If Not TypeOf doc Is DrawingDocument Then
MsgBox "Open a drawing document first"
Exit Sub
End If
Dim bp As BrowserPane
Set bp = doc.BrowserPanes("DlHierarchy")
Dim items As String
items = GetSelectedItems(bp.TopNode.BrowserNodes)
MsgBox items
End Sub


Leave a Reply to dbaCancel reply