Author Topic: Enterprise Architect Object Model and Visual Basic  (Read 9753 times)

Viking

  • EA User
  • **
  • Posts: 453
  • Karma: +2/-2
    • View Profile
Enterprise Architect Object Model and Visual Basic
« on: July 11, 2017, 03:48:15 am »
Hi,

I refer to http://sparxsystems.com/forums/smf/index.php?topic=5268.0.

I never used Visual Basic in my life. I want to access EA via VB. I do not want to install a tool. So I want to run it (with cscript) from a DOS-box.

The document mentioned above says that I have to use "Enterprise Architect Object Model" resp. EA.tlb. Can I link this library inside the script or as part of the cscript-command. Probably this is more a VB question. I hope that somebody can tell me the solution anyway.

Many thanks in advance, V.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Enterprise Architect Object Model and Visual Basic
« Reply #1 on: July 11, 2017, 02:36:19 pm »
Do you want to use VB, or VBScript?

The key to connecting to the running instance in a VBScript is to use the following:

Code: [Select]
    dim repository
    set repository = CreateObject("EA.Repository")

An example of VB(A) using EA is to be found in my Excel importer: https://bellekens.com/2015/10/24/simple-vba-excel-to-ea-importer-v4/

Geert

Viking

  • EA User
  • **
  • Posts: 453
  • Karma: +2/-2
    • View Profile
Re: Enterprise Architect Object Model and Visual Basic
« Reply #2 on: July 11, 2017, 08:13:45 pm »
Do you want to use VB, or VBScript?

The key to connecting to the running instance in a VBScript is to use the following:

Code: [Select]
    dim repository
    set repository = CreateObject("EA.Repository")

An example of VB(A) using EA is to be found in my Excel importer: https://bellekens.com/2015/10/24/simple-vba-excel-to-ea-importer-v4/

Geert

I want to access EA from outside. My understanding is that VBScript does only make sense for Scripting inside EA. We are not allowed using MS Script Debuger. That's why we are looking for alternatives.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Enterprise Architect Object Model and Visual Basic
« Reply #3 on: July 11, 2017, 10:56:49 pm »
You can also run VBScript outside of EA, but then you'll have to create the Repository as I showed you here.
When running inside EA it is added to the context for you by EA.
The code in VBA or VB is almost exactly the same.

Geert

Viking

  • EA User
  • **
  • Posts: 453
  • Karma: +2/-2
    • View Profile
Re: Enterprise Architect Object Model and Visual Basic
« Reply #4 on: July 12, 2017, 02:08:41 am »
You can also run VBScript outside of EA, but then you'll have to create the Repository as I showed you here.
When running inside EA it is added to the context for you by EA.
The code in VBA or VB is almost exactly the same.

Geert

Thank you, Geert. I get an Microsoft VBScript runtime error "ActiveX component can't create object: 'EA.Repository'". That's why I was asking, if I have to link EA.tlb (or something else) and if can access EA via VBS from a DOS-box.

Another question is, if I can access EA from Ecplise and Java. I read an anwser from Simon and my understanding is that he said, that the EA-API is not accessible from Eclipse.

Best regards, V.
« Last Edit: July 12, 2017, 02:37:17 am by Viking »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Enterprise Architect Object Model and Visual Basic
« Reply #5 on: July 12, 2017, 02:42:49 pm »
Must be an issue with the installation of EA on that machine.
Normally EA.Repository should be a registered class after you install EA.

Geert

Rich Anderson

  • EA User
  • **
  • Posts: 142
  • Karma: +8/-0
    • View Profile
    • LinkedIn
Re: Enterprise Architect Object Model and Visual Basic
« Reply #6 on: July 23, 2017, 11:03:07 pm »
I know you don't want to install a tool, but I use Visual Studio Community Edition to access and automate EA with VB.  It works very well and makes it easy to automate exchange of data between EA and other MS Office tools (mostly Excel) with code.  I suppose you could always create a console application with VS that you could run from the command line.
Rich Anderson
Urgnt Limited