MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Setting Focus

Posted by Bob on November 19, 2001 11:26 AM

If you have two programs open, say Excel and WordPad. Excel is in the
foreground, when you hit ALT-TAB, you bounce into WordPad. If you hit it again
you will be back into Excel.

Is their a way programatically to do this, without using the shell("WordPad.exe", vbNormalFocus).
I want to be able to take the focus of any program if it is running in the background.

Something like this:
shell(PreviousWindow, vbNormalFocus)


Posted by Mark O'Brien on November 19, 2001 1:38 PM

Quick answer to point you in the right direction, hopefully. Have a look at VBA help on "AppActivate". I believe that you can use the text in the title bar to reference the windows.