Forum Discussion

A2Z CF's avatar
A2Z CF
Brass Contributor
Apr 26, 2023
Solved

Sending Enter Key

Hi everyone, I have the macro in Excel which does the series of things fine but at the end where it supposed to open an external application it terminates. That external application is opening fine ...
  • NikolinoDE's avatar
    Apr 27, 2023

    A2Z CF 

    Here’s an example of how you could modify your code to send the Enter key to the external application:

    VBA.Shell "Explorer.exe C:\Users\Documents\My Application", vbNormalNoFocus
    Application.Wait (Now + TimeValue("0:00:02")) ' Wait for 2 seconds
    Application.SendKeys "{ENTER}", True

    This example, use the Application.Wait method to pause the macro for 2 seconds before sending the Enter key. This gives the external application time to open and become the active window.

     

    Or

    Application.SendKeys "{ENTER}"

    Please, keep in mind that the SendKeys command can sometimes be unpredictable and may not work as expected.

     

    Alternatively, you can try using a different library file for the external application to avoid the pop-up message altogether. If that's not possible, you could consider using a different method to open the application, such as the Shell command, which may allow you to bypass the pop-up message.

     

     

    I hope this helps!

     

Resources