Simple VBA Excel to EA importer

This tool allows to import classes and attributes from an Excel file

Usage:

  • Open Enterprise Architect
  • Select the package you wish to import the classes into.
  • Open the Excel file
  • Add content
  • Run macro "ImportFromExcel"

The tool will overwrite any classes/attribute with the same name as defined in the Excel file.

 

 

This article contains content available for registered members only. You need to be logged in to view/download this content.

About the Author

Geert Bellekens

Geert Bellekens

Bellekens IT (Consultant)
I've been active in the ICT sector since 2000 and started in 2004 as an independent modeling consultant. Over the years I've helped several major ICT players in Belgium to define and document their modeling method, train and coach the modelers, and develop supporting tools. I'm also the author of the EA Navigator http://geertbellekens.wordpress.com/ea-navigator/ , a free an open source add-in for Enterprise Architect that makes the life of any Enterprise Architect user easier by facilitating easy navigation between different elements in the model.

Comments

  • Here is the actual implementation Public Function addOrUpdateAttribute(parentClass As EA.Element, name As String, stereotype As String, description As String, attrType As String, attrLength As String, attrScale As String) As EA.Attribute Dim myAttribute As EA.Attribute 'try to find existing attribute with the given name Set myAttribute = getAttributeByName(parentClass, name) If myAttribute Is Nothing Then 'no existing attribute, create new Set myAttribute = parentClass.Attributes.AddNew(name, "Attribute") End If 'set properties myAttribute.stereotype = stereotype myAttribute.Notes = description myAttribute.Type = attrType If attrType = "CHAR" Or attrType = "NCHAR" Then myAttribute.Length = attrLength End If If attrType = "NUMBER" Then myAttribute.Precision = attrLength and myAttribute.Scale = attrScale End If 'save attribute myAttribute.Update 'refresh attributes collection parentClass.Attributes.Refresh 'return attribute Set addOrUpdateAttribute = myAttribute End Function

  • Hi, i also got a question - I extended the VBA (which is awesome by the way) in order to use it for ORACLE model. However I have severe problems with filling data type NUMBER (precision & scale) - precision is working alone - but I cannot set a scale... Do you have any idea how to overcome this obstacle? THX in adivance!

  • Hi Geert, A very big Thank you for this macro :) !!!

  • Hi Geert, I've found this Macro really useful but one thing I'm having problems with is that I don't seem to be able to get it to not sort the attributes it imports alphabetically. So far the only thing I have tried is to unselect the Tools -> Options -> Objects -> Sort Features Alphabetically option in EA but this doesn't seem to work. Any suggestions you may have as to how to achieve this would be much appreciated. Kind regards, Ben

  • Hi Geert, Thanks for the great macro, it will come into good use in our project. I was wondering if you also have a macro that imports methods (maybe including description, parameters and return type). Any help will be greatly appreciated. Sincerely, Shimon J.

  • Many thanks, works really well. Quick request - as a non VB scripter, is it possible to have a version that imports the attribute description also? Glyn

    • Glyn, Sorry for the late reply. For some reason I was not notified of comments waiting to get approved. Yes, that is rather easy. I'll update the excel file one of these days. Geert