locked
AUTOMATE IE FROM VBA RRS feed

  • Question

  • Hi All,

    I am trying to automate IE from excel VBA.

    I have a form in the webpage with id "frmIDSSTUSearch" and a text box inside the form with id "txtSTUno", i have to pass a value to that textbox from my excel macro.

    I want to enter 401 in the text box present in the webpage, this is what i m trying with. THis gives an error "Object variable or withblock variable not set.

    IE.Document.all.forms ("frmIDSSTUSearch.txtSTUno").Value = "401"

    can someone help me?

    real code

    Sub Search_Student()
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")

    IE.Navigate "http:www.studentsearch.com"
    IE.Visible = True
    While IE.Busy
      DoEvents  'wait until IE is done loading page.
    Wend

    IE.Document.all.forms ("frmIDSSTUSearch.txtSTUno").Value = "401"

    While IE.Busy
      DoEvents  'wait until IE is done loading page.
    Wend

    End Sub

    Sunday, November 15, 2009 1:31 PM

Answers

  • Hello,

    Please make sure Document.all.forms ("frmIDSSTUSearch.txtSTUno") could locate to the textbox, if I'm run this javascript:

    javascript:alert(document.forms("Form1.Text"))

    returns null when I do have a Input tag named/ID Text under Form1.

    Thanks.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Tim Li Friday, November 20, 2009 8:08 AM
    Thursday, November 19, 2009 10:30 AM