IE Text Input

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ron

    #1

    IE Text Input

    You know how some web pages require text input, well I'm doing this by
    running a VBA macro out of Excel. The macro opens IE to the desired
    url and the following lines of code insert the required text:

    Set ipf = ie.document.all .Item("XYZ")
    ipf.Value = "ABC"

    This usually works fine, but sometimes, after reviewing the source
    code behind the web page, I still can't figure out the correct "item"
    name. Is there some VBA code that would allow the macro to list the
    names of all of the "Items" for the document (e.g. the open web page),
    so that I could look at them and pick the one I need?...TIA, Ron
  • kaeli

    #2
    Re: IE Text Input

    In article <1807c7b7.04042 01412.51394706@ posting.google. com>,
    oitbso@yahoo.co m enlightened us with...[color=blue]
    > You know how some web pages require text input, well I'm doing this by
    > running a VBA macro out of Excel. The macro opens IE to the desired
    > url and the following lines of code insert the required text:
    >
    > Set ipf = ie.document.all .Item("XYZ")
    > ipf.Value = "ABC"
    >
    > This usually works fine, but sometimes, after reviewing the source
    > code behind the web page, I still can't figure out the correct "item"
    > name. Is there some VBA code that would allow the macro to list the
    > names of all of the "Items" for the document (e.g. the open web page),
    > so that I could look at them and pick the one I need?...TIA, Ron
    >[/color]

    Well, since I don't know what kind of element(s) Item is, I have to
    guess. Try this.

    This is a javascript group, and the following code is in javascript, so
    change it to VBA as you need.

    // IE only code!! Use real code instead of this IE shortcut (with a
    form) for multi-browser.

    var e = document.all.It em
    for (var i=0; i<e.length; i++)
    {
    var eName = e[i].name;
    // do whatever with e[i] based on eName
    }

    Note that if there is only one Item element, the above code will NOT
    work, as the loop would never run (length is undefined b/c it won't be
    an array). Add checking for that if it is a possibility.

    --
    --
    ~kaeli~
    Those who get too big for their britches will be exposed in
    the end.



    Comment

    Working...