# Execute EasyMorph Consult with xcl VBA

**URL:** <https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264>\
**Category:** General Q&A\
**Created:** [November 22, 2020, 7:02pm UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264 "2020-11-22T19:02:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Tarral](https://community.easymorph.com/user_avatar/community.easymorph.com/marc_tarral/32/2326_2.png) [@Marc\_Tarral](https://community.easymorph.com/u/Marc_Tarral)\
**Post date:** [November 22, 2020, 7:02pm UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/1 "2020-11-22T19:02:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [November 22, 2020, 8:47pm UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/2 "2020-11-22T20:47:11Z")

</div>

Hi Marc and welcome to the Community!

See this topic on calling Excel VBA macros from PowerShell:

> [@Importing password-protected xlsx](https://community.easymorph.com/t/importing-password-protected-xlsx/373):
>
> Hi all, Has anyone had any experience trying to import a password-protected xlsx file? I'm currently faced with the error message: 'File has wrong format. End of Central Directory record could not be found. Worksheet name cannot be changed.' Has anyone any suggestions?

Executing external applications and .bat files in explained here: [EasyMorph | Executing external programs](https://easymorph.com/learn/external-programs.html)

---

<div class="post-metadata">

**Author:** ![Marc\_Tarral](https://community.easymorph.com/user_avatar/community.easymorph.com/marc_tarral/32/2326_2.png) [@Marc\_Tarral](https://community.easymorph.com/u/Marc_Tarral)\
**Post date:** [November 22, 2020, 9:07pm UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/3 "2020-11-22T21:07:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [November 22, 2020, 9:30pm UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/4 "2020-11-22T21:30:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Marc\_Tarral](https://community.easymorph.com/user_avatar/community.easymorph.com/marc_tarral/32/2326_2.png) [@Marc\_Tarral](https://community.easymorph.com/u/Marc_Tarral)\
**Post date:** [November 23, 2020, 6:13am UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/5 "2020-11-23T06:13:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [November 23, 2020, 7:31am UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/6 "2020-11-23T07:31:47Z")

</div>

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: [Running EasyMorph projects from the command line [EasyMorph Help]](https://help.easymorph.com/doku.php?id=command_line)

---

<div class="post-metadata">

**Author:** ![Marc\_Tarral](https://community.easymorph.com/user_avatar/community.easymorph.com/marc_tarral/32/2326_2.png) [@Marc\_Tarral](https://community.easymorph.com/u/Marc_Tarral)\
**Post date:** [November 23, 2020, 8:32am UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/7 "2020-11-23T08:32:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Marc\_Tarral](https://community.easymorph.com/user_avatar/community.easymorph.com/marc_tarral/32/2326_2.png) [@Marc\_Tarral](https://community.easymorph.com/u/Marc_Tarral)\
**Post date:** [November 23, 2020, 8:41am UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/8 "2020-11-23T08:41:08Z")

</div>

![image](https://community.easymorph.com/uploads/default/original/2X/8/8a26c48b215d0794a267702ecd546b04dff44943.png)

---

<div class="post-metadata">

**Author:** ![Marc\_Tarral](https://community.easymorph.com/user_avatar/community.easymorph.com/marc_tarral/32/2326_2.png) [@Marc\_Tarral](https://community.easymorph.com/u/Marc_Tarral)\
**Post date:** [November 23, 2020, 9:04am UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/9 "2020-11-23T09:04:34Z")

</div>

![image](https://community.easymorph.com/uploads/default/original/2X/6/6fed814c7da859f9e6c97d6b665f1b2cdc797b4b.png)

---

<div class="post-metadata">

**Author:** ![Marc\_Tarral](https://community.easymorph.com/user_avatar/community.easymorph.com/marc_tarral/32/2326_2.png) [@Marc\_Tarral](https://community.easymorph.com/u/Marc_Tarral)\
**Post date:** [November 23, 2020, 9:04am UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/10 "2020-11-23T09:04:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [November 24, 2020, 10:02am UTC](https://community.easymorph.com/t/execute-easymorph-consult-with-xcl-vba/2264/11 "2020-11-24T10:02:22Z")

</div>

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.
