例如
Public MSWord As Object
Public tmp As Object
Sub ShowClassDiagrams (aCategory As Category, bVisible As Boolean, cTitle As String)
Set MSWord =CreateObject ("Word.Basic")
Set tmp =CreateObject ("Word.Basic")
MSWord.AppShow
If aCateGory.Name <>"Use Case View" Then
MSWord.EndofDoCument
MSWord.Style "标题 3"
MSWord.Insert cTitle+aCategory.Name+Chr(13)+Chr(10)
MSWord.Style "正文"
MSWord.Insert NewLine
MSWord.Insert aCategory.Documentation+NewLine
End If
m = 0
For i = 1 To aCategory.ClassDiagrams.Count
Set myDiagram = aCategory.ClassDiagrams.GetAt (i)
MyDiagram.RenderToClipboard
MSWord.EndofDocument
MSWord.Style "标题 3"
MSWord.Insert cTitle+Str$(i)+myDiagram.name+Chr(13)+Chr(10)
MSWord.Style "正文"
MSWord.Insert Chr(13)+Chr(10)
MSWord.CharLeft
MSWord.EditPaste
MSWord.EndofDocument
'myDiagram.Visible = bVisible
Next i
If i>1 Then
m = m + i -1
End If
For i = 1 To aCategory.ScenarioDiagrams.Count
Set SDiagram = aCategory.ScenarioDiagrams.GetAt (i)
SDiagram.RenderToClipboard
MSWord.EndofDocument
MSWord.Style "标题 3"
MSWord.Insert cTitle+Str$(m+i)+SDiagram.name+Chr(13)+Chr(10)
MSWord.Style "正文"
MSWord.Insert NewLine
MSWord.Insert SDiagram.Documentation + NewLine
MSWord.EditPaste
MSWord.EndofDocument
MSWord.Insert NewLine
Next i
If i>1 Then
m = m + i -1
End If
If aCategory.GetRoseItem.StateMachineOwner.StateMachines.GetAt(1) Is Not Nothing Then
For i = 1 To aCategory.GetRoseItem.StateMachineOwner.StateMachines.GetAt(1).Diagrams.Count
Set ADiagram = aCategory.GetRoseItem.StateMachineOwner.StateMachines.GetAt(1).Diagrams.GetAt (i)
ADiagram.RenderToClipboard
MSWord.EndofDocument
MSWord.Style "标题 3"
MSWord.Insert cTitle+Str$(m+i)+ADiagram.name+Chr(13)+Chr(10)
MSWord.Style "正文"
MSWord.Insert Chr(13)+Chr(10)
MSWord.Insert ADiagram.Documentation+NewLine
MSWord.CharLeft
MSWord.EditPaste
MSWord.EndofDocument
MSWord.Insert NewLine
Next i
End If
If i>1 Then
m = m + i - 1
End If
For i = 1 To aCategory.UseCases.Count
Set UCase = aCategory.UseCases.GetAt (i)
MSWord.EndofDocument
MSWord.Style "标题 3"
MSWord.Insert cTitle+Str$(m+i)+UCase.name+NewLine
MSWord.Style "正文"
MSWord.Insert UCase.Documentation+NewLine
MSWord.EndofDocument
MSWord.Insert NewLine
If UCase.StateMachine Is Not Nothing Then
MSWord.Insert UCase.StateMachine.Documentation + NewLine
For j =1 To UCase.StateMachine.Diagrams.Count
Set ADiagram = UCase.StateMachine.Diagrams.GetAt(j)
ADiagram.RenderToClipBoard
MSWord.Style "正文"
MSWord.Insert "●"+ ADiagram.Name+Chr(13)+Chr(10)
MSWord.Insert Chr(13)+Chr(10)
MSWord.EditPaste
MSWord.EndofDocument
MSWord.Insert Chr(13)+Chr(10)
Next j
End If
For j = 1 To UCase.ScenarioDiagrams.Count
Set SDiagram = UCase.ScenarioDiagrams.GetAt (j)
SDiagram.RenderToClipboard
MSWord.EndofDocument
MSWord.Style "正文"
MSWord.Insert Chr(13)+Chr(10)
MSWord.Insert "●"+SDiagram.name+Chr(13)+Chr(10)
MSWord.Insert SDiagram.Documentation + NewLine
MSWord.EditPaste
MSWord.EndofDocument
MSWord.Insert Chr(13)+Chr(10)
Next j
For j =1 To UCase.ExternalDocuments.Count
Set myFile = UCase.ExternalDocuments.GetAt(j)
If Right$(myFile.Path,4) =".doc" Then
tmp.FileOpen myFile.Path
tmp.EditSelectAll
tmp.EditCopy
tmp.FileClose
MSWord.EndofDocument
MSWord.Insert Chr(13)+Chr(10)
MSWord.EditPaste
MSWord.EndofDocument
MSWord.Insert Chr(13)+Chr(10)
End If
Next j
Next i
If i>1 Then
m = m + i - 1
End If
For k = 1 To aCategory.Categories.Count
Call ShowClassDiagrams (aCategory.Categories.GetAt (k), bVisible,cTitle+Str$(m+k)+".")
Next k