title: How do I set focus on another open application?
body: <p>I'm trying to create a button in My VBA excel code that when pushed it sets focus on another open windows application and inserts some text. I found some code that kinda works, but it doesn't switch to the other application, it opens a new one. how can I have it switch to the already open application?</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>Public vPID As Variant
  Private Sub CommandButton1_Click()
      vPID = Shell("C:\Windows\system32\notepad.exe", vbNormalFocus)
      Application.Wait (Now() + TimeValue("00:00:01"))
      SendKeys "test" + "{ENTER}"
  End Sub
  </code></pre>
  
  <p>I am a beginner, and any help would be greatly appreciated!
  Thank You</p>