12-03-2010, 08:34 AM
To return error/success status, exe files use an exit code.
To set an exit code, simply return it from your exe-macro. Example: ret 1.
But VBA Shell() function does not give you the exit code.
Need to use some other function.
Run this macro once.
It creates a small dll "qmvbrun.dll" and puts it in your system folder. QM must be running as admin.
The dll has function VbRun. It runs a program (must be program, not document or folder etc), waits, and returns its exit code.
The function can be used in Excel macros and other VB or VBA code.
Macro Macro1497
Excel macro example
To set an exit code, simply return it from your exe-macro. Example: ret 1.
But VBA Shell() function does not give you the exit code.
Need to use some other function.
Run this macro once.
It creates a small dll "qmvbrun.dll" and puts it in your system folder. QM must be running as admin.
The dll has function VbRun. It runs a program (must be program, not document or folder etc), waits, and returns its exit code.
The function can be used in Excel macros and other VB or VBA code.
Macro Macro1497
__Tcc x.Compile("" "$system$\qmvbrun.dll" 2)
#ret
#include <windows.h>
__declspec(dllexport)
int VbRun(LPSTR program, LPSTR cmdLine)
{
_spawnlp(0, program, " ", cmdLine, 0);
__asm__("leave;ret $8"); //make stdcall
}
Excel macro example