+ Reply to Thread
Results 1 to 10 of 10

Interaction with Internet Explorer

  1. #1
    Ron
    Guest

    Interaction with Internet Explorer

    Hi guys,

    If I wanted to send say 10 or so numerical values from excel to 10 or so
    input boxes in a web page how would I go about it?

    Is it possible to do this through excel and maybe a custom form, or would
    it be more efficient with a stand alone VB program?

    The values will change in excel every once in a while, and need to be
    copy/pasted into the relevant input boxes in the web page. These input
    boxes in the web page stay constant in position, is it possible through
    screen position?

    Regards,

    Ron

  2. #2
    PaulD
    Guest

    Re: Interaction with Internet Explorer


    "Ron" <[email protected]> wrote in message
    news:[email protected]...
    : Hi guys,
    :
    : If I wanted to send say 10 or so numerical values from excel to 10 or so
    : input boxes in a web page how would I go about it?
    :
    : Is it possible to do this through excel and maybe a custom form, or would
    : it be more efficient with a stand alone VB program?
    :
    : The values will change in excel every once in a while, and need to be
    : copy/pasted into the relevant input boxes in the web page. These input
    : boxes in the web page stay constant in position, is it possible through
    : screen position?
    :
    : Regards,
    :
    : Ron

    Does the webpage allow tabs to cycle through the fields? Could you use
    sendkeys?
    Paul D



  3. #3
    Ron
    Guest

    Re: Interaction with Internet Explorer


    >
    > Does the webpage allow tabs to cycle through the fields? Could you use
    > sendkeys?
    > Paul D
    >
    >
    >




    Hi Paul,

    Yes the web page will tab through the input boxes, and I have thought about
    the sendkeys method but am unsure of the syntax as I've not yet used this
    method.

    I'm still learning VBA, so any examples would be more than helpful.

    Thanks,

    Ron

  4. #4
    PaulD
    Guest

    Re: Interaction with Internet Explorer


    "Ron" <[email protected]> wrote in message
    news:[email protected]...
    :
    : >
    : > Does the webpage allow tabs to cycle through the fields? Could you use
    : > sendkeys?
    : > Paul D
    : >
    :
    : Hi Paul,
    :
    : Yes the web page will tab through the input boxes, and I have thought
    about
    : the sendkeys method but am unsure of the syntax as I've not yet used this
    : method.
    :
    : I'm still learning VBA, so any examples would be more than helpful.
    :
    : Thanks,
    :
    : Ron
    :

    Ron,
    Here is an example from the help file if using sendkeys from Excel

    SendKeys Statement Example
    This example uses the Shell function to run the Calculator application
    included with Microsoft Windows. It uses the SendKeys statement to send
    keystrokes to add some numbers, and then quit the Calculator. (To see the
    example, paste it into a procedure, then run the procedure. Because
    AppActivate changes the focus to the Calculator application, you can't
    single step through the code.). On the Macintosh, use a Macintosh
    application that accepts keyboard input instead of the Windows Calculator.
    Dim ReturnValue, I
    ReturnValue = Shell("CALC.EXE", 1) ' Run Calculator.
    AppActivate ReturnValue ' Activate the Calculator.
    For I = 1 To 100 ' Set up counting loop.
    SendKeys I & "{+}", True ' Send keystrokes to Calculator
    Next I ' to add each value of I.
    SendKeys "=", True ' Get grand total.
    SendKeys "%{F4}", True ' Send ALT+F4 to close Calculator.

    If you want to try using sendkeys from a script, here is an old script I
    used to use to bypass the outlook security (not needed with 2003). You
    would need to make a reference to Excel and read the data from the
    spreadsheet then use sendkeys to fill out the form.

    i=0
    Set fso = CreateObject ("WScript.Shell")
    While fso.AppActivate ("Microsoft Outlook") = FALSE
    wscript.sleep 300
    i = i + 1
    if i = 15 then wscript.quit
    Wend
    fso.SendKeys "a",True
    fso.SendKeys "{TAB}{TAB}",True
    fso.SendKeys "{Enter}",True
    Set fso=Nothing

    Paul D



  5. #5
    Ron
    Guest

    Re: Interaction with Internet Explorer

    Hi Paul (and anyone else who can help)

    I tried the example from the help file and it ran fine, however when I
    changed it somewhat it seems to fail.

    This is what I tried..

    Sub SendkeysTest()
    Dim proggy
    proggy = Shell("C:\Program Files\Internet Explorer\iexplore.exe", 3)
    AppActivate proggy 'THIS IS WHERE IT FAILS
    SendKeys "{TAB}"
    SendKeys "www.google.com"
    SendKeys "~"
    End Sub


    This opens an IE window ok, but then the window doesn't get focus. When
    the line 'AppActivate proggy' comes round the code gives an error.

    The sendkeys lines actually work fine, but what they seem to be doing is
    sending the keys to the vbe itself, because the 'www.google.com' gets
    inserted on the line where the insertion point is in the code.

    Thanks for the help so far.

    Ron

  6. #6
    Forum Contributor
    Join Date
    12-11-2004
    MS-Off Ver
    2007
    Posts
    137
    Hello Ron , Hello paul

    i'm not sure to understand what you want , but you may try this macro to insert cells value in webpage input


    Sub piloterPageWeb()
    'activate Microsoft HTML Objects Library reference
    'activate Microsoft Internet Controls reference
    Dim i As Integer
    Dim IE As InternetExplorer
    Dim maPageHtml As HTMLDocument
    Dim Helem As IHTMLElementCollection

    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True

    IE.navigate "http://www.pagesjaunes.fr/pj.cgi?"
    Do Until IE.readyState = READYSTATE_COMPLETE
    DoEvents
    Loop 'wait end loading

    Set maPageHtml = IE.document
    Set Helem = maPageHtml.getElementsByTagName("input")

    '*******************************
    '(exemple to indentify the "input" objects in the page)
    'For i = 0 To Helem.Length - 1
    'MsgBox i & Helem(i).getAttribute("name") & " / " & Helem(i).getAttribute("value")
    'Next i
    '*******************************

    With Helem
    .Item(16).innerText = Range("A1") 'Nom
    .Item(17).innerText = Range("A2") 'Adresse
    .Item(18).innerText = Range("A3") 'Localité
    End With

    'Helem(20).Click 'Run webPage Button "Recherche"

    End Sub



    regards ,
    michel

  7. #7
    PaulD
    Guest

    Re: Interaction with Internet Explorer


    "Ron" <[email protected]> wrote in message
    news:[email protected]...
    : Hi Paul (and anyone else who can help)
    :
    <snip>
    : Sub SendkeysTest()
    : Dim proggy
    : proggy = Shell("C:\Program Files\Internet Explorer\iexplore.exe", 3)
    : AppActivate proggy 'THIS IS WHERE IT FAILS
    : SendKeys "{TAB}"
    : SendKeys "www.google.com"
    : SendKeys "~"
    : End Sub
    :
    :
    : This opens an IE window ok, but then the window doesn't get focus. When
    : the line 'AppActivate proggy' comes round the code gives an error.
    <snip>

    Ron,
    The problem here is the code is much faster than the computer. When you
    start your shell to IE, the program has not loaded by the time you are
    trying to activate it and this causes an error. You have to slow down the
    code a bit. I'm sure there are much more resourceful ways of doing this but
    a 'brute force' method is creating a wait command
    Application.Wait (Now + TimeValue("0:00:5"))
    this will make the code pause 5 seconds while waiting for the IE to load.
    Keep in mind you can have the same problem with sendkeys. This worked on my
    machine
    Sub SendkeysTest()
    Dim proggy As Long
    proggy = Shell("C:\Program Files\Internet Explorer\iexplore.exe", 3)
    Application.Wait (Now + TimeValue("0:00:5"))
    AppActivate proggy 'THIS IS WHERE IT FAILS
    SendKeys "{TAB}"
    SendKeys "www.google.com"
    Application.Wait (Now + TimeValue("0:00:1"))
    SendKeys "~"
    End Sub

    Paul



  8. #8
    Ron
    Guest

    Re: Interaction with Internet Explorer


    >
    > Ron,
    > The problem here is the code is much faster than the computer. When
    > you start your shell to IE, the program has not loaded by the time you
    > are trying to activate it and this causes an error. You have to slow
    > down the code a bit.




    Thanks Paul, works ok on mine also. However when/if I actually use this I
    want to have the IE window already open, logged in to the web page and then
    I will manually bring up the input box/boxes. How do I tell the code which
    specific App to activate.

    When I get to the ....proggy = Shell("C:\Program Files\....line of code it
    opens a fresh blank IE window. This is not what I want. I want it to
    activate an existing version of IE.

    Any suggestions appreciated.

    Thanks again Paul.

    Ron

  9. #9
    Ron
    Guest

    Re: Interaction with Internet Explorer

    Hi again Paul,


    A bit of research shows that AppActivate "Google" or even AppActivate
    "Goo" will give the IE window with the google page focus.

    Thanks for all the help Paul.


    Ron

  10. #10
    PaulD
    Guest

    Re: Interaction with Internet Explorer

    "Ron" <[email protected]> wrote in message
    news:[email protected]...
    : Hi again Paul,
    :
    : A bit of research shows that AppActivate "Google" or even AppActivate
    : "Goo" will give the IE window with the google page focus.
    :
    : Thanks for all the help Paul.
    :
    : Ron

    You're welcome. And for anyone else following this thread
    http://www.freevbcode.com/ShowCode.asp?ID=526
    has some code for how to "Activate an App by a Partial Window Title"
    Paul D



+ 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