469,622 Members | 1,548 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,622 developers. It's quick & easy.

IE Text Input

ron
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
Jul 23 '05 #1
1 1595
In article <18**************************@posting.google.com >,
oi****@yahoo.com enlightened us with...
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


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.Item
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.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Marios Koumides | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.