Run macros from java

Luiz Henrique Silva

Run macros from java

Hello experts,

would anyone help me to execute a macro from java?

im use to write my macros in vba, and i want to transform them into a java application. 

I have a app made in swing/awt and want it to execute the  BAS or CATScript or CATvba.

I have Tried searching for this on internet but still found nothing

ps: im using vs code

Edited By:
Luiz Henrique Silva[Subscriber Members] @ Sep 30, 2022 - 11:13 AM (America/Sao_Paulo)

Marc D. Young

RE: Run macros from java
(in response to Luiz Henrique Silva)

Hello Luiz,

There should be several ways to achieve this :

  • COM4J
  • Apache POI
  • From Java with the Runtime class call the .vbs 

There is another way to consider is to use Python. All the VBS can be translated to Python.

Also EKL with Know How Apps can execute VBA and VBS.

Though regardless of technology used time will need to be spent to architect and streamline the solution.  I would be happy to discuss more off line at +1.248.926.5932 / [login to unmask email]

Best Regards,

Marc Young

www.xlmsolutions.com

Alex Bruskin

RE: Run macros from java
(in response to Luiz Henrique Silva)

CATvba operates with COM objects, which means it either needs a wrapper - either local or as a service. It almost doesn't matter if you call it from .NET or Java or JavaScript - though for JavaScript you will probably need something like ElectronJS. The biggest question is what exactly are you trying to achieve in this experiment? I agree with Marc that it can be architectured differently depending on the functional requirements.

Edited By:
Alex Bruskin[Senticore Technologies] @ Oct 04, 2022 - 09:29 AM (Europe/Prague)

Luiz Henrique Silva

RE: Run macros from java
(in response to Marc D. Young)

Hello marc, thank you for your answer, I will search for these items!

I want make my macros a stand alone application to avoid keep updating it in every computer in my company, so my intent is to have only one application located on network where designers can reach it. =)

Luiz Henrique Silva

RE: Run macros from java
(in response to Alex Bruskin)

Hello Alex,
Thanks for you answer, 

My intent is to have only one app with all my macros, so I will have to update it only one time instead of getting shorcut on customize/tools/new command...etc.
Besides,  these shortcuts keep disappearing sometimes and users need me to get it again.

I choose java because it more simple(I think) to use GUI, in python im just know about tkinter and kiwi

Marc A Jeeves

RE: Run macros from java
(in response to Luiz Henrique Silva)

i would create it as a VBA macro in 3dx and reference it in Data Setup this way you can deploy to all users via a CATSettings change

Alex Bruskin

RE: Run macros from java
(in response to Marc A Jeeves)

I second Marc Jeeves. Probably better to expose it centrally via 3DX and then refer to via CATSettings. However, if you can share more details about your environment, it will provide a better context: version of 3DX, version of CATIA, Windows or Linux for server side, etc.

Edited By:
Alex Bruskin[Senticore Technologies] @ Oct 04, 2022 - 09:34 AM (Europe/Prague)