Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default trouble with onchange event

I'm not sure where to go with this question so I thought I'd try this
group.

I'm having some trouble with the following VBA code. The varTags
variable is sometimes empty, and sometimes it has what it's supposed
to have. I always use the same set of pages to test.

I thought maybe the page needed time to load, so I added in
Do While obIe.Busy & Do While obIe.readyState <4
DoEvents loops after the onchange call, but they had no effect.

The onchange call does in fact load the expected page, it's the line
of code afterwards that doesn't always work. Any ideas?

Thank you

Public Function submitDropDownData(IeDoc As Object, obIe As Object,
elementToSelect As Long, elementValue As String, ID As String)
Dim el As Object
Dim varTags as Variant
Dim tagType as String

tagType="td"

Set el = IeDoc.getElementsByName(ID)
el(0).children(elementToSelect).Selected = True
el(0).children(elementToSelect).Value = elementValue
el(0).onchange

Set varTags = IeDoc.getElementsByTagName(tagType)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default trouble with onchange event

In this code, the varTags variable would be a collection of <td tags. Are
there no td tags on the page you are using?

"Dudely" wrote:

I'm not sure where to go with this question so I thought I'd try this
group.

I'm having some trouble with the following VBA code. The varTags
variable is sometimes empty, and sometimes it has what it's supposed
to have. I always use the same set of pages to test.

I thought maybe the page needed time to load, so I added in
Do While obIe.Busy & Do While obIe.readyState <4
DoEvents loops after the onchange call, but they had no effect.

The onchange call does in fact load the expected page, it's the line
of code afterwards that doesn't always work. Any ideas?

Thank you

Public Function submitDropDownData(IeDoc As Object, obIe As Object,
elementToSelect As Long, elementValue As String, ID As String)
Dim el As Object
Dim varTags as Variant
Dim tagType as String

tagType="td"

Set el = IeDoc.getElementsByName(ID)
el(0).children(elementToSelect).Selected = True
el(0).children(elementToSelect).Value = elementValue
el(0).onchange

Set varTags = IeDoc.getElementsByTagName(tagType)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default trouble with onchange event

Yes, there are in fact quite a few <td tags on the page. I've since
determined that sleeping for a length of time resolves the problem as
it gives the page enough time to load. At this point, what I don't
understand is why "Do While obIe.Busy & Do While obIe.readyState <4"
don't work.

Someone else in another group stated "Quite obvious, there is no
direct HTTP request here."

So it's "quite obvious". Unfortunately, the obnoxious *******
couldn't be troubled to provide a solution, no doubt because that's
"quite obvious" as well.

Perhaps someone else could provide the obvious solution (that's better
than the one I figured out) to someone as dense as myself.

Thank you







On Oct 9, 8:00*pm, AndyM wrote:
In this code, the varTags variable would be a collection of <td tags. *Are
there no td tags on the page you are using?



"Dudely" wrote:
I'm not sure where to go with this question so I thought I'd try this
group.


I'm having some trouble with the following VBA code. *The varTags
variable is sometimes empty, and sometimes it has what it's supposed
to have. *I always use the same set of pages to test.


I thought maybe the page needed time to load, so I added in
Do While obIe.Busy & Do While obIe.readyState <4
DoEvents loops after the onchange call, but they had no effect.


The onchange call does in fact load the expected page, it's the line
of code afterwards that doesn't always work. *Any ideas?


Thank you


Public Function submitDropDownData(IeDoc As Object, obIe As Object,
elementToSelect As Long, elementValue As String, ID As String)
Dim el As Object
Dim varTags as Variant
Dim tagType as String


tagType="td"


Set el = IeDoc.getElementsByName(ID)
el(0).children(elementToSelect).Selected = True
el(0).children(elementToSelect).Value = elementValue
el(0).onchange


Set varTags = IeDoc.getElementsByTagName(tagType)- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default trouble with onchange event

It is possible that your code ("Do While obIe.Busy & Do While obIe.readyState
<4") is being executed before the HTTP request.

Try this before your code:

Do Until obIe.Busy Or obIe.readyState < 4
DoEvents
Loop

This will make sure your code will wait until the HTTP request begins. Your
code could get stuck in this loop though, so you would want to add in a time
limit to exit out of the loop.


"Dudely" wrote:

Yes, there are in fact quite a few <td tags on the page. I've since
determined that sleeping for a length of time resolves the problem as
it gives the page enough time to load. At this point, what I don't
understand is why "Do While obIe.Busy & Do While obIe.readyState <4"
don't work.

Someone else in another group stated "Quite obvious, there is no
direct HTTP request here."

So it's "quite obvious". Unfortunately, the obnoxious *******
couldn't be troubled to provide a solution, no doubt because that's
"quite obvious" as well.

Perhaps someone else could provide the obvious solution (that's better
than the one I figured out) to someone as dense as myself.

Thank you







On Oct 9, 8:00 pm, AndyM wrote:
In this code, the varTags variable would be a collection of <td tags. Are
there no td tags on the page you are using?



"Dudely" wrote:
I'm not sure where to go with this question so I thought I'd try this
group.


I'm having some trouble with the following VBA code. The varTags
variable is sometimes empty, and sometimes it has what it's supposed
to have. I always use the same set of pages to test.


I thought maybe the page needed time to load, so I added in
Do While obIe.Busy & Do While obIe.readyState <4
DoEvents loops after the onchange call, but they had no effect.


The onchange call does in fact load the expected page, it's the line
of code afterwards that doesn't always work. Any ideas?


Thank you


Public Function submitDropDownData(IeDoc As Object, obIe As Object,
elementToSelect As Long, elementValue As String, ID As String)
Dim el As Object
Dim varTags as Variant
Dim tagType as String


tagType="td"


Set el = IeDoc.getElementsByName(ID)
el(0).children(elementToSelect).Selected = True
el(0).children(elementToSelect).Value = elementValue
el(0).onchange


Set varTags = IeDoc.getElementsByTagName(tagType)- Hide quoted text -


- Show quoted text -



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnChange event attached to tick box [email protected] Excel Programming 4 August 7th 08 12:39 PM
onCHange event geebee Excel Programming 1 June 9th 08 05:17 PM
Populating cells based on a combobox OnChange Event [email protected] Excel Programming 1 April 25th 07 03:32 AM
OnChange Event for a Cell Michael Kintner Excel Programming 3 January 5th 04 08:29 PM


All times are GMT +1. The time now is 07:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"