Using the MODELENGLib library (Microsoft Visio Database Modeling Engine Type Library) 
Author Message
 Using the MODELENGLib library (Microsoft Visio Database Modeling Engine Type Library)

Hi

I am trying to add columns to exisiting data entites using the
Microsoft Visio Database Modeling Engine Type Library.

I have been able to add columns but cannot add/modify the default
datatype.  There is a provided structure called IVMEDataType which
supplies 3 readonly properties.  As they are readonly I cannot set
them.  The actual DataType property of the IVMEAttribute object is not
readonly.

The problem is it defualts to char(10) as the datatype and I was
trying to find a way (through code) to change the default value
(instead of char(10)) or even create a DataType object and assign that
to the IVMEAttribute object.

My code appears below.  Any help would be greatly appreciated.  

I am using Visio for Enterprise Architects (10.0.2705)

Public Sub pCreateExtraColumns()
    Dim vme As New VisioModelingEngine
    Dim models As IEnumIVMEModels
    Dim model As IVMEModel
    Dim erModel As IVMEERModel
    Dim entities As IEnumIVMEEntities
    Dim entity As IVMEEntity
    Dim attrs As IEnumIVMEAttributes
    Dim attr As IVMEAttribute
    Dim ivDataType As IVMEDataType
    Dim intColumnNumberCount As Integer
    Dim strDataType As String

    Set models = vme.models

    Do Until Not (model Is Nothing)
        Set model = models.Next

        If Not (model Is Nothing) Then
            If (model.ModelKind = eVMEModelERLogical) Then
                Set erModel = model
                Set entities = erModel.entities

                Do
                    Set entity = entities.Next
                    If Not (entity Is Nothing) Then
                        Debug.Print entity.PhysicalName
                        Set attrs = entity.Attributes
                        intColumnNumberCount = 0
                        Do
                            Set attr = attrs.Next
                            If Not (attr Is Nothing) Then
                                intColumnNumberCount =
intColumnNumberCount + 1
                            End If
                        Loop Until (attr Is Nothing)
                        Set attr = entity.CreateAttribute()
                        Set ivDataType = attr.DataType
                        attr.ColumnNumber = intColumnNumberCount
                        attr.PhysicalName = "TestColumnName"
            '            strDataType = "varchar(100)"
            '            ivDataType.PhysicalName = strDataType 'this
line does not work as PhysicalName is readonly
                        attr.DataType = ivDataType
                    End If
                Loop Until (entity Is Nothing)
            End If
        End If
    Loop
End Sub



Mon, 07 Nov 2005 07:19:02 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Visio 2000 Database Modeling Engine Type Library

2. Use Visio Database Modeling Engine Programmaticaly?

3. Visio Database Modeling Engine

4. CR Engine Obj Lib vs CR Designer Component Obj Model

5. Problem with the Visio Modeling Engine

6. Visio Database Model export

7. An IE type library or object Model

8. Creating Gantt Charts using the Visio Object Model

9. Using Library (*.lib) Files with Visual Basic

10. link to static library using vb (*.lib file)

11. How to expose table and column information in a database model using VBA and the Visio object model?

12. How to make reference to Microsoft Outlook Express 5.0 type Library

 

 
Powered by phpBB® Forum Software