
Originally Posted by
Dave
Recall that I mentioned that the code to be ran must be in a module and that the syntax (as provided) has to be correct. This code should activate the application and bring it to the foreground. Dave
AppActivate xlApp.ActiveWindow.Caption & " - " & xlApp.Caption
xlApp.WindowState = 1 'wdWindowStateMaximize
This did the trick.
The exact code I implemented is such:
'Pulling apart the subject line/body information and into vars...
'With selected outlook email item
For Each Item In Application.ActiveExplorer.Selection
'Particularly with the subject...
Subj = Item.Subject
'MsgBox "Subj " & Subj
On Error GoTo SubjErr1
...
'Activate the workbook like a user clicked it
AppActivate xlApp.ActiveWindow.Caption
'Excel window is pulled to front as though a user had clicked it for focus
...
'Runs a macro on that same book
xlWB.Application.Run "UpdateNOBRAINER", NameSubj, EDTSubj, BodT(0), RNum
Thank you very much for your help!
Now it switches back and forth like I desired. When a new email comes in, it's scooped up by the OnNewMail event listener I set up and processed. Then it activates my Excel book and opens it up like a user clicked it. It does some fancy macro magic and then arrives with the cursor over a specific data line. Then it goes back to "sleep" and waits for more.
Thank you again!