W
Wozza
Hi
I am trying to generate some SQL from a database model diagram in Visio Pro
2003 using VBA.
I have got as far as trying to iterate thru the AttributeAnnotations but get
an error ...
I get a run time error 445 - Object doesn't support this action on the line
(currently commented out below):
Set myAttributeAnnotations = myAttribute.AttributeAnnotations
Can anyone see what I am doing wrong?
rgds
Warren
Sub testModels()
Static vme As New VisioModelingEngine
Dim models As IEnumIVMEModels
Set models = vme.models
Dim model As IVMEModel
Do Until Not model Is Nothing
Set model = models.Next
Call testModel(model)
Loop
End Sub
Sub testModel(ByRef model As IVMEModel)
Debug.Print model.FileName
Debug.Print model.IsDirty
Debug.Print model.IsRunningModalDialog
Debug.Print model.ModelKind
Select Case model.ModelKind
Case eVMEModelERLogical
Debug.Print "ER Logical Model Kind"
Case eVMEModelERSource
Debug.Print "ER Source Model Kind"
Case eVMEModelORMSource
Debug.Print "ORM Source Model Kind"
Case eVMEModelUndefined
Debug.Print "Undefined Model Kind"
Case eVMEModelUnspecified
Debug.Print "Unspecified Model Kind"
Case eVMEModelUpperBound
Debug.Print "Upper Bound Model Kind"
End Select
Call testElements(model.elements)
End Sub
Sub testElements(myElements As IEnumIVMEModelElements)
Dim myElement As IVMEModelElement
Dim myEntity As IVMEEntity
Dim myAttributes As IEnumIVMEAttributes
Dim myAttribute As IVMEAttribute
Dim myAttributeAnnotations As IEnumIVMEAttributeAnnotations
Dim myAttributeAnnotation As IVMEAttributeAnnotation
Set myElement = myElements.Next
Do While Not myElement Is Nothing
Debug.Print myElement.ElementID, myElement.Type
If myElement.Type = eVMEKindEREntity Then
Set myEntity = myElement
Debug.Print myEntity.Name
Set myAttributes = myEntity.Attributes
Set myAttribute = myAttributes.Next
Do While Not myAttribute Is Nothing
Debug.Print myAttribute.Name, myAttribute.Type,
myAttribute.CollectionType
'Set myAttributeAnnotations = myAttribute.AttributeAnnotations
'Set myAttributeAnnotation = myAttributeAnnotations.Next
'Do While Not myAttributeAnnotation Is Nothing
' Debug.Print myAttributeAnnotation.Type
' Set myAttributeAnnotation = myAttributeAnnotations.Next
'Loop
Set myAttribute = myAttributes.Next
Loop
End If
Set myElement = myElements.Next
Loop
'todo myElements.clone
'todo myElements.skip
'todo myElements.reset
End Sub
I am trying to generate some SQL from a database model diagram in Visio Pro
2003 using VBA.
I have got as far as trying to iterate thru the AttributeAnnotations but get
an error ...
I get a run time error 445 - Object doesn't support this action on the line
(currently commented out below):
Set myAttributeAnnotations = myAttribute.AttributeAnnotations
Can anyone see what I am doing wrong?
rgds
Warren
Sub testModels()
Static vme As New VisioModelingEngine
Dim models As IEnumIVMEModels
Set models = vme.models
Dim model As IVMEModel
Do Until Not model Is Nothing
Set model = models.Next
Call testModel(model)
Loop
End Sub
Sub testModel(ByRef model As IVMEModel)
Debug.Print model.FileName
Debug.Print model.IsDirty
Debug.Print model.IsRunningModalDialog
Debug.Print model.ModelKind
Select Case model.ModelKind
Case eVMEModelERLogical
Debug.Print "ER Logical Model Kind"
Case eVMEModelERSource
Debug.Print "ER Source Model Kind"
Case eVMEModelORMSource
Debug.Print "ORM Source Model Kind"
Case eVMEModelUndefined
Debug.Print "Undefined Model Kind"
Case eVMEModelUnspecified
Debug.Print "Unspecified Model Kind"
Case eVMEModelUpperBound
Debug.Print "Upper Bound Model Kind"
End Select
Call testElements(model.elements)
End Sub
Sub testElements(myElements As IEnumIVMEModelElements)
Dim myElement As IVMEModelElement
Dim myEntity As IVMEEntity
Dim myAttributes As IEnumIVMEAttributes
Dim myAttribute As IVMEAttribute
Dim myAttributeAnnotations As IEnumIVMEAttributeAnnotations
Dim myAttributeAnnotation As IVMEAttributeAnnotation
Set myElement = myElements.Next
Do While Not myElement Is Nothing
Debug.Print myElement.ElementID, myElement.Type
If myElement.Type = eVMEKindEREntity Then
Set myEntity = myElement
Debug.Print myEntity.Name
Set myAttributes = myEntity.Attributes
Set myAttribute = myAttributes.Next
Do While Not myAttribute Is Nothing
Debug.Print myAttribute.Name, myAttribute.Type,
myAttribute.CollectionType
'Set myAttributeAnnotations = myAttribute.AttributeAnnotations
'Set myAttributeAnnotation = myAttributeAnnotations.Next
'Do While Not myAttributeAnnotation Is Nothing
' Debug.Print myAttributeAnnotation.Type
' Set myAttributeAnnotation = myAttributeAnnotations.Next
'Loop
Set myAttribute = myAttributes.Next
Loop
End If
Set myElement = myElements.Next
Loop
'todo myElements.clone
'todo myElements.skip
'todo myElements.reset
End Sub