Set focus to application opened when using ShellExecute

I use the following line of code as part of a public sub routine to open various types of files from within Access:
 iRet = ShellExecute(Forms("frmActivity").hWnd, "open", sDocFileNamePath, "", "", nCmdShow)

The code will open any file where the extension has been associated with a program, but the problem is as soon as the file opens, the form goes back to Access instead of the file that's been opened.  nCmdShow is a numeric value that is supposed to set whether the program is opened minimized, maximized, etc, but it doesn't matter what numeric value I use here, the application still minimizes after opening.
LVL 6
Mach1proAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GRayLCommented:
Add the line:

AppActivate iRet
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GRayLCommented:
Type Alt+F11 to get to the VBA window, and enter AppActivate in the Help window.  Also read up on Shell
0
Mach1proAuthor Commented:
That seems to work for most applications. Tends to throw up an error when activating Excel. Since Excel isn't going to be launched that much, I just trapped the error and went with it.
Thanks
0
GRayLCommented:
Thanks, glad to help.  No reason I can think of why it should not work for Excel.  Go to the VBA window and in the immediate pane repeat the code you used to Open Excel.  Here you execute one line at a time.  Make sure you have the path for both Excel, and the spreadsheet down correctly, and don't forget the double quotes.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.