VBA Ready State Statement

excelenergy

Board Regular
Joined
Jun 7, 2012
Messages
142
Hello,

Im trying to pass some information to a webform, and my script works to open the page, and select a radio button, but after the radio button is selected, the script stops passing my data to the webform.

All my code is in place to do what I want....But yet the VBA Script isnt passing the data. And I think it has something to do with this statement:

Rich (BB code):
 Do Until IE.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop

Here is my full code, but it would probably be better if you downloaded my workbook here:
http://www.fileswap.com/dl/fM0ITxXDrZ/SEDI_Macro.xlsm.html


Full Code:


Rich (BB code):
Option Explicit
Private Sub macro1()
    ' Set a reference to 'Microsoft Internet Controls' under the VBA Tools\References menu
    Dim IE As InternetExplorer
    Dim IO As InternetExplorer
    Dim aa As Object    'HTMLInputElement
    Dim ab As Object    'HTMLSelectElement
    Dim ac As Object    'HTMLSelectElement
    Dim ad As Object    'HTMLSelectElement
    Dim ae As Object    'HTMLSelectElement
    Dim af As Object    'HTMLSelectElement
    Dim ag As Object    'HTMLSelectElement
    Dim ah As Object    'HTMLSelectElement
    Dim ai As Object    'HTMLSelectElement
    Dim Button As Variant
    Dim Form As Variant
    Dim HTMLdoc As HTMLDocument
    
Set IE = New InternetExplorer
    
With IE
    IE.navigate "https://www.sedi.ca/sedi/SVTReportsAccessController?menukey=15.03.00&locale=en_CA&gx_session=0"
    IE.Visible = True
    Do
        DoEvents
    Loop Until IE.readyState = 4
    
    IE.document.all("ChosenReport").Item(0).Checked = True
    
    'Select Units
    'IE.Document.All("ChosenReport").Item(0).Checked = True
    IE.document.forms(0).submit
End With
With IE
Do Until IE.readyState = READYSTATE_COMPLETE
        DoEvents
    Loop
Set ab = .document.getElementByName("SELECT_TYPE")
ab.selectedIndex = 4
Set aa = .document.getElementByName("SELECT_TYPE_VALUE")
aa.Value = Range("B3")
Set ac = .document.getElementByName("SELECT_TYPE_VALUE_SEARCH_TYPE")
ac.Value = Range("C3")
Set ad = .document.getElementByName("DATE_RANGE_TYPE")
ad.selectedIndex = 0
Set ae = .document.getElementByName("MONTH_FROM_PUBLIC")
ae.Value = Range("D3")
Set af = .document.getElementByName("YEAR_FROM_PUBLIC")
af.Value = Range("F3")
Set ag = .document.getElementByName("MONTH_TO_PUBLIC")
ah.Value = Range("G3")
Set ah = .document.getElementByName("DAY_TO_PUBLIC")
ah.Value = Range("H3")
Set ai = .document.getElementByName("YEAR_TO_PUBLIC")
ai.Value = Range("I3")
Set Button = .document.getElementById("Submit")
Button.Click

End With
End Sub
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top