Book a Demo

Author Topic: Import information items from excel  (Read 8846 times)

minna

  • EA User
  • **
  • Posts: 64
  • Karma: +1/-0
    • View Profile
Import information items from excel
« on: February 27, 2014, 06:16:11 pm »
Hi,

I have a collection of information items in an excel spreadsheet. Can I import them into a diagram in EA?

Thanks,
Minna

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import information items from excel
« Reply #1 on: February 27, 2014, 07:42:24 pm »
Minna,

You should be able to do that with my Excel Importer

Geert

minna

  • EA User
  • **
  • Posts: 64
  • Karma: +1/-0
    • View Profile
Re: Import information items from excel
« Reply #2 on: February 27, 2014, 09:07:13 pm »
Hi Geert,

Thanks for the feedback. If I understand your tutorial correctly, then I need to add 'InformationItem' to the spreadsheet (Type) and add all my information items there. Then I need to change the VBA code to add these 'InformationItems' to EA since there is no 'InformationItem' in EA.Element.Type.

Am I correct in my statement? Is there another way of adding InformationItems to EA using Excel without writing any VBA code?

Thanks,
Minna

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import information items from excel
« Reply #3 on: February 27, 2014, 09:43:54 pm »
It's been a while since I wrote the code, but I thought you simply had to set the type field to InformationItem.

I'll try it myself and I'll let you know.

Geert

minna

  • EA User
  • **
  • Posts: 64
  • Karma: +1/-0
    • View Profile
Re: Import information items from excel
« Reply #4 on: February 27, 2014, 11:25:00 pm »
Hi Geert,

Thanks. I will also try just changing the type to InformationItems. I will give my feedback as soon as I have done it (might be only tomorrow).

Looking forward to your feedback.

Regards,
Minna

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Import information items from excel
« Reply #5 on: February 28, 2014, 02:09:12 am »
Indeed InformationItem is to be supplied in the element type field when you create it. That should create the right one.
Code: [Select]
Pk.Elements.AddNew ("new", "InformationItem");
q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import information items from excel
« Reply #6 on: February 28, 2014, 05:44:24 pm »
I just checked myself and there's a case missing in the operation
EAConnector.isValidElementType(elementType As String)

You'll need to add
Code: [Select]
Case "InformationItem"
    isValidElementType = True

I'll update the version on my site this weekend.

Geert

minna

  • EA User
  • **
  • Posts: 64
  • Karma: +1/-0
    • View Profile
Re: Import information items from excel
« Reply #7 on: February 28, 2014, 08:26:03 pm »
Hi Geert,

Thanks, it works great.

Another thing I want to add is connectors (InformationFlow and Associations) to existing classes in a diagram. I added a Source and Target column header. In those columns I tried adding the class names as well as their GUID. This didn't work.

Should I add extra code in VBA?

Thanks,
Minna

minna

  • EA User
  • **
  • Posts: 64
  • Karma: +1/-0
    • View Profile
Re: Import information items from excel
« Reply #8 on: February 28, 2014, 09:08:37 pm »
Another quick question. How do I get the ElementID of a class in EA? I can only see the GUID in the properties view.

Thanks!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import information items from excel
« Reply #9 on: February 28, 2014, 09:09:04 pm »
In order to add relations you'll need to add extra code.
There's currently no operation in the EAConnector class to add connectors.
You'll have to do something similar to addOrUpdateAttribute but instead of adding a new attribute you'll have to add a new connector.
Code: [Select]
parentClass.Connectors.AddNew (...
There are a few good examples on the forum on how to add a connector to an element.

Geert

minna

  • EA User
  • **
  • Posts: 64
  • Karma: +1/-0
    • View Profile
Re: Import information items from excel
« Reply #10 on: February 28, 2014, 09:12:05 pm »
Thanks. I will look at the forum for examples.

Quick question, How do I get the ElementID of a class in EA? I can only see the GUID in the properties view.

Thanks!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import information items from excel
« Reply #11 on: February 28, 2014, 09:19:42 pm »
I don't think you can without doing a little query on the database.

Geert

minna

  • EA User
  • **
  • Posts: 64
  • Karma: +1/-0
    • View Profile
Re: Import information items from excel
« Reply #12 on: March 11, 2014, 11:45:43 pm »
Hi Geert,

I was going through your 'Simple VBA Excel to EA importer v3' tutorial. I noticed in EAConnector the first line states 'Dim EARepos As EA.repository'.

This might be a stupid question, but how does excel know that EA (in EA.repository) refer to the current Enterprise Architect model that is open on my pc?

Thanks,
Minrie

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13471
  • Karma: +571/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import information items from excel
« Reply #13 on: March 12, 2014, 01:48:45 am »
Because the import operation uses
Code: [Select]
Public Function getSelectedPackage() As EA.package
    Dim aEArepository As EA.repository
    'if the repository is not already know get the repository
    If EARepos Is Nothing Then
        'get the currently opened repository
        Set aEArepository = Me.[highlight]getCurrentRepository[/highlight]
    Else
        Set aEArepository = EARepos
    End If
and getCurrentRepository does:
Code: [Select]
Public Function getCurrentRepository() As EA.repository
    Dim EAapp As EA.App
    Dim EArepository As EA.repository
    [highlight]Set EAapp = GetObject(, "EA.App")[/highlight]
    'Warning when EA not open
    If EAapp Is Nothing Then
        MsgBox "Please Open Enterprise Architect"
        'try again
        Set getCurrentRepository = Me.getCurrentRepository
    End If
    'Warning when no repository is opened.
    Set EArepository = EAapp.repository
    If EArepository Is Nothing Then
        MsgBox "Please open a Model in Enterprise Architect"
        'try again
        Set getCurrentRepository = Me.getCurrentRepository
    End If
    'return the found repository
    Set getCurrentRepository = EAapp.repository
End Function

Geert
« Last Edit: March 12, 2014, 01:49:28 am by Geert.Bellekens »

minna

  • EA User
  • **
  • Posts: 64
  • Karma: +1/-0
    • View Profile
Re: Import information items from excel
« Reply #14 on: March 12, 2014, 07:47:13 pm »
Hi Geert,

I copied and pasted the code in all the modules as it is in 'Simple VBA Excel to EA importer v3'. I get a error in EAConnector on the top line 'Dim EARepos As EA.repository'. The error is 'User-defined type is not defined'.

This error make sense to me since Excel need to know what 'EA' refers to in 'Dim EARepos As EA.repository'. If I were using visual studio, I would have probably added a reference of Enterprise Architect so that the compiler knows what 'EA' refers to.

How do let Excel know what 'EA' refers to? How does Excel know to go look for an open model of Enterprise Architect?

Thanks,
Minna