|
-
May 30th, 2013, 10:41 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Assistance needed with filling out internet forms from MS Excel using VBA
I have VBA code that goes online and automatically registers individuals for track and field competitions using performance data found in the Excel spreadsheet.
This code worked fine last year but now I am receiving errors. I believe I found the culprit but will need assistance on solving the problem.
Here is the relavant code
Code:
Dim oBrowser As Object
Set oBrowser = GetObject("", "InternetExplorer.Application")
Dim URLcoll As New Collection
Dim ipf As Variant
dim URL as string:URL = "http://www....."
With oBrowser
.Silent = True
.navigate URL
.Visible = True
Do While .Busy Or .readyState <> 4: Loop
End With
Set ipf = oBrowser.document.getElementsByTagName("a")
For counter = 3 To ipf.Length - 1
URLcoll.Add ipf(counter).href
Next
The problem occurs when setting the ipf object. When I step through the code while debugging, the next line of code executes fine. However, when I run the code, I get an error message indicating that the object is not set. It appears that
Code:
For counter = 3 To ipf.Length - 1
is being executed before ipf is ready. My assumption is that the next line of code would not execute until the variable is ready so I did not initially put in any wait commands. I eventually inserted a delay, starting at 1 second and ramping all the way up to 5 seconds before it was able to run without error. I then inserted the 5 second delay througout my subroutine (adding about a minute to the processing time!).
My next approach is the create a while loop that waits until ipf <> Nothing, but before doing that, i thought it would be prudent to try and get to the heart of the problem. Again, it worked like a charm last year. Is it possible that a change occured via a Microsoft Update that changes the way internet explorer operates? I am seeing this error across 4 computers (all 4 worked last year.)
Thank you.
-
May 30th, 2013, 12:24 PM
#2
Thread Starter
Addicted Member
Re: Assistance needed with filling out internet forms from MS Excel using VBA
I figured it out.
I needed to either use variant or IHTMLElementCollection instead of object.... go figure
Last edited by adrian1906; May 30th, 2013 at 02:26 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|