Control ED through VBA

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
DjZU
Posts: 10
Joined: Friday 13 April, 2012 - 10:03

Control ED through VBA

Post by DjZU »

Hello !

As the title said, I would like to run and control Enterprise Dynamics through Excel with VBA code. I'm used to work with the following function to open files with the associated program, declared like this:

Code: Select all

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
and called like this:

Code: Select all

unused = ShellExecute(0, vbNullString, ThisWorkbook.Path & "/Simulation.mod", vbNullString, ThisWorkbook.Path & "/", vbNormalFocus)
It works but it doesn't meet my need as I would like to run ED first, and then open a model because the result is not the same. Actually, the previous code acts like if I was double clicking a .MOD file and I need a code that would acts like if I was double clicking ED.exe and then from ED clicking 'Open Model' to load the same .MOD file.

I'm wondering how to achieve this goal and obviously need a clue.

Cheers,

DjZU
DjZU
Posts: 10
Joined: Friday 13 April, 2012 - 10:03

Re: Control ED through VBA

Post by DjZU »

Hello ED Community!

I finally get by with a slight change in the call of ED by VBA:

Code: Select all

unused = ShellExecute(0, vbNullString, ThisWorkbook.Path & "\Simulation.mod", vbNullString, ThisWorkbook.Path & "\", vbNormalFocus)
I provided the directory parameter and change "/" by "\"... It will maybe help someone else ;)

Cheers,

DjZU
Post Reply