+ Reply to Thread
Results 1 to 2 of 2

SendKeys Trouble

Hybrid View

  1. #1
    MTechG
    Guest

    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. #2
    MTechG
    Guest

    RE: 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
    >
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1