SendKeys Trouble

G

Guest

I've got an excel spreadsheet that I'm trying to toggle between two
applications. The second application takes up the whole screen and doesn't
allow the start bar to come backup. It's a measuring application and the
screen has to be a certain size so no it can't be changed. You can alt tab
back and forth between the two while it's running no problem.

This is the code I tried to run and it worked 2-3 time so I put it in the
production routine and now it works sometimes other times the Numlock caption
comes up on the screen and nothing happens. What the sub is doing is
toggling between two apps. It minimizes XL and then Maximizes the second
application.

Is there a better way to do this?

TIA
D
Sub Run()
Dim stProgram As String
stProgram = Range("Application").Value
Application.WindowState = xlMinimized

AppActivate (stProgram)
DoEvents
SendKeys "%" & Chr$(vbKeySpace) & "X"

Application.Wait (Now + TimeValue("0:00:03"))

AppActivate (stProgram)
DoEvents
SendKeys "%" & Chr$(vbKeySpace) & "N"

Application.Wait (Now + TimeValue("0:00:03"))

Application.WindowState = xlNormal

End Sub
 

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