Runtime Error 91 Object Variable or With block not set

mogseyoboyle

New Member
Joined
Oct 8, 2014
Messages
1
Hi Guys

I am new to web controls in VBA and I can't figure this out.

I have a webbrowser control on a spreadsheet, and I am trying to login to a website using VBA. When I run the code I get a runtime error 91 message (where hightlighted).

Code:
Sub logIn(webBr As webBrowser, user As String, pass As String, URL As String)
    
    With webBr
        .Navigate URL
        .Visible = True
        Do While .Busy: DoEvents: Loop
        Do While .ReadyState <> 4: DoEvents: Loop
        With .Document
            
            [highlight].all("user").Value = user [/highlight]
            .all("pass").Value = pass
            '.website.Value = "stw"
            .submit.Click
        
        End With
        Do While .Busy: DoEvents: Loop
        Do While .ReadyState <> 4: DoEvents: Loop
    End With
End Sub

I have figured a workaround if I can read in the page source, but I can't figure that out either yet.

Sorry if I haven't provided enough information, I am new to this.

I am using Office 2010 Pro Plus with Win 7

Any help would be most appreciated.

Thanks in advance

Mogsey
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,214,999
Messages
6,122,645
Members
449,093
Latest member
Ahmad123098

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