VBA: Please Help. Runtime Error during "DoEvents Loop"

Peter h

Active Member
Joined
Dec 8, 2015
Messages
417
Hey guys, I'm hoping someone can help me out here. I'm manipulating a webform with a userform for work. I'm getting a Run time error 91: "Object Variable or With block variable not set." on the highlighted line of code.

Code:
Set IE = New SHDocVw.InternetExplorerMedium
IE.Visible = True
IE.Navigate Nav
Do
    DoEvents
Loop Until IE.ReadyState = READYSTATE_COMPLETE

Set WF = IE.Document

With WF
    .getElementById(SType).selectedIndex = Me.ListBox1.ListIndex + 1
    .getElementById(SType).FireEvent ("onchange")
End With
Do
    DoEvents
Loop While WF.getElementById(CROList) Is Nothing

Set e = WF.getElementById("ListBox1")
i = 0
    For Each o In e.Options
        If o.Value = Me.TextBox2.Text Then
            e.selectedIndex = o.Index
            e.FireEvent ("onchange")
            Exit For
        End If
        i = i + 1
        If i > e.Length Then
            MsgBox "Sample was not found."
            Exit For
        End If
    Next o
Do
    DoEvents
[COLOR=#FF0000]Loop Until WF.getElementById("btnAccept").Disabled = True
[/COLOR]
If Me.CheckBox1.Visible = True Then
    If WF.getElementById("Incl_Daily_Average").Checked = True Then
        Me.CheckBox1 = True
    Else
        Me.CheckBox1 = False
    End If
End If
IE.Quit
Set IE = Nothing

When I step through the code I don't get the error. It's only when I try to run the code. Any ideas?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,215,784
Messages
6,126,878
Members
449,347
Latest member
Macro_learner

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