Message 1 of 2
Sketched symbols...still

Not applicable
09-27-2007
07:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following code will find the sketched symbol called "hex" and call up the insert dialog for sketched symbols with "hex" highlighted. How do I modify this code to bypass the dialog and just start the insert?
Public Sub InsertSymbol()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
' Get the sketched symbol named "?".
Dim sSketchSymbolName As String
sSketchSymbolName = "Hex"
Dim oNode As BrowserNode
Set oNode = GetSymbolNode(oDrawDoc.BrowserPanes.ActivePane.TopNode, sSketchSymbolName)
' Select the symbol.
Dim oSelectSet As SelectSet
Set oSelectSet = oDrawDoc.SelectSet
oSelectSet.Clear
oNode.DoSelect
' Execute the Insert Drawing Sketch Symbol command.
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingSymbolsCmd").Execute
End Sub
Private Function GetSymbolNode(ByVal TopNode As BrowserNode, ByVal SymbolName As String) As BrowserNode
' Iterate through the children of the input node.
Dim oNode As BrowserNode
For Each oNode In TopNode.BrowserNodes
' Look for the "Sketched Symbols node".
If oNode.BrowserNodeDefinition.Label = "Sketched Symbols" Then
' Find the specified node.
Dim oSymbolNode As BrowserNode
For Each oSymbolNode In oNode.BrowserNodes
If UCase(oSymbolNode.BrowserNodeDefinition.Label) = UCase(SymbolName) Then
' Assign the node as the output value and exit the function.
Set GetSymbolNode = oSymbolNode
Exit Function
End If
Next
End If
' Check if the node has been found and exit the function.
If Not GetSymbolNode Is Nothing Then
Exit Function
Else
' Recursively call this function to traverse the browser tree.
Set GetSymbolNode = GetSymbolNode(oNode, SymbolName)
End If
Next
End Function
Public Sub InsertSymbol()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
' Get the sketched symbol named "?".
Dim sSketchSymbolName As String
sSketchSymbolName = "Hex"
Dim oNode As BrowserNode
Set oNode = GetSymbolNode(oDrawDoc.BrowserPanes.ActivePane.TopNode, sSketchSymbolName)
' Select the symbol.
Dim oSelectSet As SelectSet
Set oSelectSet = oDrawDoc.SelectSet
oSelectSet.Clear
oNode.DoSelect
' Execute the Insert Drawing Sketch Symbol command.
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingSymbolsCmd").Execute
End Sub
Private Function GetSymbolNode(ByVal TopNode As BrowserNode, ByVal SymbolName As String) As BrowserNode
' Iterate through the children of the input node.
Dim oNode As BrowserNode
For Each oNode In TopNode.BrowserNodes
' Look for the "Sketched Symbols node".
If oNode.BrowserNodeDefinition.Label = "Sketched Symbols" Then
' Find the specified node.
Dim oSymbolNode As BrowserNode
For Each oSymbolNode In oNode.BrowserNodes
If UCase(oSymbolNode.BrowserNodeDefinition.Label) = UCase(SymbolName) Then
' Assign the node as the output value and exit the function.
Set GetSymbolNode = oSymbolNode
Exit Function
End If
Next
End If
' Check if the node has been found and exit the function.
If Not GetSymbolNode Is Nothing Then
Exit Function
Else
' Recursively call this function to traverse the browser tree.
Set GetSymbolNode = GetSymbolNode(oNode, SymbolName)
End If
Next
End Function