Execute EasyMorph Consult with xcl VBA

Hi, I would like to know if someone can help me to execute Easymorph and a specific sql consult+extraccion from Excel with vba code.

Could be i suppose:

  1. Through Powersheel specifying the consukt in parameter
  2. Creating a . bat and executing it

Thanks a lot in advance

Hi Marc and welcome to the Community!

See this topic on calling Excel VBA macros from PowerShell:

Executing external applications and .bat files in explained here: https://easymorph.com/learn/external-programs.html

Hi and Thanks
On the first topic i was more thinking about launching a “querry + exls extraccion” project from an excel.xlsm program and then integrate the new data into that excel.xlsm with vba code like:

Sub crearbat()
ruta1 = ThisWorkbook.Path
ruta2 = ruta1 & “\bbdd_prod.xls”
Set fs = CreateObject(“Scripting.FileSystemObject”)
Set a = fs.CreateTextFile(ruta1 & “\extractor.bat”, True)

fini = Split(Sheets(“PARAMETROS”).Cells(10, 2).Value, “/”)
ffin = Split(Sheets(“PARAMETROS”).Cells(11, 2).Value, “/”)
d1 = fini(0) & “/” & fini(1) & “/” & fini(2)
d2 = ffin(0) & “/” & ffin(1) & “/” & ffin(2)
ruta = Split(ruta1, “”)

param00 = “H:”
param01 = "cd " & Right(ruta1, 7)
llam1 = Sheets(“PARAMETROS”).Cells(12, 2).Value
llam2 = Chr(34) & d1 & Chr(34) & " " & Chr(34) & d2 & Chr(34)
llam3 = Chr(34) & ruta2 & Chr(34) & " " & Chr(34) & “marc” & Chr(34)
param2 = llam1 & " " & llam2 & " " & llam3

a.WriteLine param00
a.WriteLine param01
a.WriteLine param2
a.Close
End Sub

Sub extract()
Dim lValDev As Long
ruta1 = ThisWorkbook.Path
ruta10 = ruta1 & “\extractor.bat”
param2 = “extractor.bat”
lValDev2 = ShellExecute(0, “OPEN”, ruta10, param2, “”, 0)
End Sub

I’m not sure I follow you. What’s your question exactly?

To launch easymorph on a second plan from an other application.and close it once the data are collected and extracted to an file in a specific folder

I would like to do it createting and executing a .bat file for example.

The question is what should i write in that .bat file

Thanks

OK, now I understand. Thanks for the clarification. EasyMorph projects can be executed from the command line and .bat files. See this help article for more details: https://help.easymorph.com/doku.php?id=command_line

Hi, Thanks for the info. I have try that command:
morph.exe /c /report bbdd_c28_v3.morph

but windows tell me that it can not find the morph.exe file.

image

Maybe is because i am still working with the demo version…

Yes, the free edition doesn’t allow running EasyMorph from the command line. You can request a trial key right in the application, on the Start screen. It will be delivered automatically.