none
AppActivate and Sendkeys not working. RRS feed

  • Question

  • The following works starting in Excel and opening iexplorer.  It also copies my StrucNum correctly because when I get to Google Maps I can hit Ctrl-V and it pastes in.  I just can't get it to go by code.  Something goes wrong at AppActivate and after.

    THANKS!!!

    Sub SearchStrucNum()
    '
    ' SearchStrucNum Macro
    '
    ' Keyboard Shortcut: Ctrl+a
    '

        Dim myNum As Integer
        Dim x As String
        Dim Path As String
              
        Columns("B:B").Select
       
        myNum = Application.InputBox("Enter StrucNum")

       
        Selection.Find(What:=myNum, After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
           
        mySting = ActiveCell.Offset(0, 2).Select
       
        Selection.copy
           
        ' Set the Path variable equal to the path of your program's installation
        Path = "C:\Program Files\Internet Explorer\Google Map iexplore.exe"
       
        x = Shell(Path, vbNormalFocas)
       
        AppActivate x, True
       
        SendKeys "^V" & "~"
       
                   
    End Sub

    Thursday, January 2, 2014 7:26 PM

All replies

  • What happens if you single step through the code.  I have had problems with the code running to quickly and having to add waits.
    Thursday, January 2, 2014 8:25 PM
  • No problems stepping through until:

     AppActivate x, True
     SendKeys "^V" & "~"

    The problem is getting the code to send the focus to the entry box in Google Maps, doing the Ctrl-V (paste lat and long) and hit the return key.

    Thanks!  Greg

    Thursday, January 2, 2014 8:52 PM