Option Explicit
Private Sub Command1_Click()
On Error GoTo errorHandler
Dim oTaggedText As New [Link]
Dim lNumStreams As Long
Dim arrStreamNames() As String
Dim iCounter As Integer
Dim sData As String
Dim oDomDoc As DOMDocument
Dim oNode As IXMLDOMNode
Dim oChildNode As IXMLDOMNode
Dim oRootStorageHelper As [Link]
Dim oDocument As [Link]
Dim oApplication As [Link]
Dim ii As Integer
Dim oMyLoader As [Link]
Const STR_Storage As String = "TaggedTxtData"
On Error Resume Next
Set oApplication = GetObject(, "[Link]")
On Error GoTo errorHandler
Set oMyLoader = New CLoader
[Link] "[Link]"
If Not oApplication Is Nothing Then
Set oDocument = [Link]
If Not oDocument Is Nothing Then
'// NOTE: You'll have to use this Helper object to get the root storage
of the
'// Document you want to process. Then call .SetStorage() with
the return from
'// GetRootStorage() <instead of using .SetFileName()>; you can
use .SetFileName()
'// without running SmartSketch, if you want. This example uses
the ActiveDocument.
'// It can be any Document...
'//
Set oRootStorageHelper = New [Link]
[Link] [Link](oDocument)
Else
MsgBox "No Active Document!"
GoTo done
End If
Else
'// Open a File with the Tagged Text library
'// Works with files that are not actively loaded in a running instance of
SmartSketch.
'//
[Link] "C:\Temp\[Link]"
End If
'// Get the stream names and count from the TaggedTxtData storage
'//
[Link] STR_Storage, lNumStreams, arrStreamNames
[Link] "Number of Streams = " & lNumStreams
If lNumStreams <> 0 Then
'// Loop through all the streams...
'//
For iCounter = 1 To lNumStreams
'// Read the data from the stream
'//
[Link] STR_Storage, arrStreamNames(iCounter), sData
'// Create a DOMDocument and load the data into it
'//
Set oDomDoc = New DOMDocument
If [Link](sData) Then
'// Loop through the root level nodes of the DOMDocument
'//
Set oNode = [Link]
Do
[Link] [Link]
'// If it has child Nodes...
'//
If [Link] > 0 Then
'// Loop through the child nodes of the root node
'//
Set oChildNode = [Link]
Do
[Link] "..." & [Link] & " = " &
[Link]
'// Let's change the value of the DrawingNumber field
'//
If [Link] = "DrawingNumber" Then
[Link] = "DrawingNumber by VB"
End If
'// Get the next sibling of the Child node
'//
If Not [Link] Is Nothing Then
Set oChildNode = [Link]
Else
Set oChildNode = Nothing
End If
Loop While Not oChildNode Is Nothing
End If
'// Get the next sibling of the root level node
'//
If Not [Link] Is Nothing Then
Set oNode = [Link]
Else
Set oNode = Nothing
End If
Loop While Not oNode Is Nothing
End If
'// Now write the data back to the stream
'//
sData = [Link]
[Link] STR_Storage, arrStreamNames(iCounter), sData
Set oDomDoc = Nothing
Next
End If
done:
'// IMPORTANT NOTE:
'// ALWAYS call Complete or else you will not be able to open the file again
'// until you log off and log back in!
'// NEVER set a break point after opening the file and then stop debugging
'// without calling complete (see above)
'//
If Not oTaggedText Is Nothing Then
[Link] 1
End If
Set oTaggedText = Nothing
Set oMyLoader = Nothing
If Not oDocument Is Nothing Then
[Link] oDocument
Set oDocument = Nothing
End If
Set oRootStorageHelper = Nothing
Exit Sub
errorHandler:
MsgBox [Link] & " - " & [Link]
GoTo done
End Sub
Private Sub Command2_Click()
End
End Sub