ShellExecuteEx in VBA

前端 未结 3 1541
粉色の甜心
粉色の甜心 2020-12-20 05:05

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

3条回答
  •  被撕碎了的回忆
    2020-12-20 05:21

    Use 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:

    1. It is recommended directly by manufacturer. There can be several reasons behind it including recent one:

    2. 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.

提交回复
热议问题