I understand how to use ShellExecute in VBA (for my Outlook macros) but I\'m looking to be able to use ShellExecuteEx to wait for the executed program in my script. Does an
CreateProcess() Windows API call instead.For running a process and waiting until it finishes, use solution recommended by Microsoft which calls CreateProcessA(). Do not use ShellExecuteEx(). (You can also consider replacing your existing code.)
Reasons:
It is recommended directly by manufacturer. There can be several reasons behind it including recent one:
It is stable. ShellExecuteEx() is reported to throw exception after recent (2015) Windows updates when it is called from VBA.
In the answer to the above linked question, the code from Microsoft article is ready-to-use as separate VBA module.