The sleep might not be sufficient (try longer sleeps). Check for the existence of the Excel window via
WinWait (and then add perhaps some
sleep anyway).
Is there a reason why you don't create the Excel instance via
ComObjCreate ?
Also this might be relevant:
https://support.microsoft.com/en-us/hel ... pplication
[...]
When an Office application starts, it does not immediately register its running objects. This optimizes the application's startup process. Instead of registering at startup, an Office application registers its running objects in the ROT once it loses focus. Therefore, if you attempt to use GetObject or GetActiveObject to attach to a running instance of an Office application before the application has lost focus, you might receive one of the errors above.
Resolution
Using code, you can change focus from the Office application to your own application (or to some other application) to allow it to register itself in the ROT. Additionally, if your code is launching the Office application's exe file, you might need to wait for the Office application to finish loading before attempting to attach to the running instance.[...]