Des of VBA I execute a bat using Call Shell (...) and it works correctly.
Now I need to pick up the answer of this bat, which has an "Echo answer".
Any ideas on how to do this?
Thank you,
Des of VBA I execute a bat using Call Shell (...) and it works correctly.
Now I need to pick up the answer of this bat, which has an "Echo answer".
Any ideas on how to do this?
Thank you,
I have answered in SO in English. Answer Here
I enclose a translation.
You can not return a response using Call Shell
. You need to use WScript.Shell
.
Dim sh As Object
Set sh = CreateObject("WScript.Shell")
Dim ex As Object
Set ex = sh.Exec("C:\Directorio\A\Archivo.bat")
Dim ans As String
ans = ex.StdOut.ReadAll
In a more summarized way, if you want to save lines:
Dim ans As String
ans = CreateObject("WScript.Shell").Exec("C:\Directorio\A\Archivo.bat").StdOut.ReadAll