title: Using AppActivate and Sendkeys in VBA shell command
body: <p>I want to switch back and forth between application with the shell command in VBA.
  I am using SendKeys to do stuff in process A then move to process B, then to process A then process B.  It works fine for the first iteration.  When I use AppActivate to go back to process B, it actually does switch focus back to process B.  HOWEVER, it ignores subsequent commands from SendKeys.</p>
  
  <p>Example code:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Sub pastePDF2TXT_v3(pdfName As String, txtName As String)
  
  
  Dim acrobatID
  Dim acrobatInvokeCmd As String
  Dim acrobatLocation As String
  
  Dim notepadID
  
  Dim acrobatID2
  Dim notepadID2
  
  Debug.Print "here"
  
  
  acrobatLocation = "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"
  
  acrobatInvokeCmd = acrobatLocation &amp; " " &amp; pdfName
  
  acrobatID = Shell(acrobatInvokeCmd, 1)
  AppActivate acrobatID
  SendKeys "^a", True  '^A selects everything already in the pdf file.
  SendKeys "^c", True  '^C copies the selection to the clipboard.
  
  
  
  notepadID = Shell("NOTEPAD.EXE " &amp; txtName, 1)  ' invoke notepad on the text file.
  AppActivate notepadID                           ' set the new app as teh active task.
  
  SendKeys "^a", True  '^A selects everything already in the text file.
  SendKeys "^v", True  '^V pastes the new stuff over the top of the old text file (deleting the old stuff)
  SendKeys "%{END}", True ' makre sure last line of text file 
  SendKeys "{ENTER}", True
  
  
  
  AppActivate acrobatID  ' NOTE: APPEARS TO WORK UP TO THIS POINT.
  
  SendKeys "{ENTER}", True  ' NOTE: SECOND APP IGNORES SUBSEQUENT COMMANDS FROM HERE DOWN.
  SendKeys "^a", True  '^A selects everything already in the pdf file.
  SendKeys "^c", True  '^C copies the selection to the clipboard.
  SendKeys "%f", True  'alt f, x to exit Notepad.exe
  SendKeys "x", True
  'acrobatID.Quit
  
  
  Debug.Print "start second"
  
  AppActivate notepadID                           ' set the new app as teh active task.
  
  
  SendKeys "%{END}", True 'Go to end of text file.
  SendKeys "^v", True  '^V pastes the new stuff at end of file.
  SendKeys "{ENTER}", True
  
  SendKeys "^s", True   
  
  SendKeys "%f", True   'alt f, x to exit Notepad.exe
  SendKeys "x", True
  
  notepadID.Quit
  acrobatID.Quit
  
  End Sub
  </code></pre>