Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

strange automate IE error

1 view
Skip to first unread message

mscir

unread,
Sep 21, 2005, 10:22:17 PM9/21/05
to
I'm trying to update values in a page opened from VB

Dim IE as object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate App.Path & "\pageofinterest.htm"

This works:
IE.Document.All("visitdate").Value = SomeValue

This doesn't !
Dim inputname as string
inputname = "visitdate"
IE.Document.All.Item(inputname).Value = SomeValue

Is there any way I can update the text boxes and lists using names
stored in an array or collection?

Thanks,
Mike

Tony Spratt

unread,
Sep 22, 2005, 5:52:05 AM9/22/05
to
> I'm trying to update values in a page opened from VB
>
> Dim IE as object
> Set IE = CreateObject("InternetExplorer.Application")
> IE.Navigate App.Path & "\pageofinterest.htm"
>
> This works:
> IE.Document.All("visitdate").Value = SomeValue
>
> This doesn't !
> Dim inputname as string
> inputname = "visitdate"
> IE.Document.All.Item(inputname).Value = SomeValue

The "All.Item" syntax returns a collection of items rather than an
individual item. You would need to assign final value to the individual
items in the collection:

[warning - air code]

Dim strInName as String
Dim objCollect as Object
Dim objItem as Object

strInName = "visitdate"
Set objCollect = IE.Document.All.Item(strInName)

For Each objItem in objCollect
objItem.Value = "Whatever"
Next

mscir

unread,
Sep 22, 2005, 6:17:09 AM9/22/05
to
Tony Spratt wrote:
> The "All.Item" syntax returns a collection of items rather than an
> individual item. You would need to assign final value to the individual
> items in the collection:
>
> [warning - air code]
>
> Dim strInName as String
> Dim objCollect as Object
> Dim objItem as Object
>
> strInName = "visitdate"
> Set objCollect = IE.Document.All.Item(strInName)
>
> For Each objItem in objCollect
> objItem.Value = "Whatever"
> Next

Thanks for the post. I found this approach that works for text boxes,
selects, and more:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20660197.html

Mike

0 new messages