[HELP] closing a program with VBA code

A

Andr? Palmela

Hello
I need help for closing an aplication in the end of an Excel Sub()
I tried the code:
-------------------------------------------------------------------
AppActivate "IML Device 1", False
SendKeys "%{F4}", False
DoEvents
AppActivate "IML Device 1", False
DoEvents
SendKeys "ENTER", False
DoEvents
--------------------------------------------------------------------

i will have to send the ALT+F4 command to close and then press "enter"
because it is one of those programs that ask if you "really whant to
close" ...
The problem is that the "ENTER" comand i send it's not making
anything...
The program remains with the question that "do you really what to
close" and does not close.
Any ideia for resolving this problem ?
I already made searches over the internet and i didn't find the
answer.

Thank You
Regards
André Palmela
 
T

Tom Ogilvy

try putting all the keystrokes in one line. This should put them in the
keyboard buffer for that program and it will process them as it needs them.

AppActivate "IML Device 1", False
SendKeys "%{F4}~", False
DoEvents
 
M

Myrna Larson

You are sending the 5 letters E, N, T, E, and R, not the ENTER key. You must
use codes for all of the special keys, just as you do for the function keys.
Help lists them. To send the ENTER key, you put it in braces, just as you did
with F4, or use ~

I believe you should be able to do it with one statement.

SendKeys "%{F4}{ENTER}", False
 

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