Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SendKeys Trouble
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
SendKeys Trouble
I found this link and it works great!
http://vbnet.mvps.org/index.html?cod...estorehwnd.htm Dennis "MTechG" wrote: 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 |