Pass control back to Excel window

H

Hendy88

Hello again,

I was wondering if anyone knows how to pass control back to Excel after
the macro opens another application. What I have is a macro that opens
an Emulator window, then I have a UserForm that prompts the user to
enter their UserName. The problem is that the Emulator window is in
front of Excel at that point and you cannot see the UserForm behind it.
All it does it "flashes" the Excel window control in the TaskBar. Of
course, once you click on it, it then brings Excel up to the top of the
Z-Index/Level.

What I'm wondering is if there's a way to program part of the macro to
maybe "focus" back on the Excel application/workbook/worksheet AFTER
the Emulator application is opened. Reason why, is some users (believe
it or not) are just not smart enough to click on something they see
flashing at the bottom of the screen. They'll sit there and wait and
wait, calling me telling me it's not doing anything. When it fact it's
really waiting for them.

I just want to take this step out of the equation, so that I don't have
to worry about someone getting "hung up" at this point. Perhaps maybe
a BringWindowToTop() Function?

Thanks in advance!
Steve
 
H

Harlan Grove

(e-mail address removed) wrote...
....
What I'm wondering is if there's a way to program part of the macro to
maybe "focus" back on the Excel application/workbook/worksheet AFTER
the Emulator application is opened. Reason why, is some users (believe
it or not) are just not smart enough to click on something they see
flashing at the bottom of the screen. They'll sit there and wait and
wait, calling me telling me it's not doing anything. When it fact it's
really waiting for them.
....

Presumably you're using VBA's Shell function to start the other
application. If so, you could use the second argument to Shell to
prevent it from receiving focus when it starts. That would leave Excel
with focus.

Also, Shell is asynchronous, so Excel macro execution continues after
starting the other application. You could start yet another application
*with* focus, perhaps Internet Explorer displaying a message like

Click on the flashing Excel icon on the bottom of your screen, moron!

(or perhaps something a bit more polite) before displaying the user
form.

Then there's always

AppActivate Application.Caption

to return focus to Excel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top