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
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Watch MrExcel Video

Forum statistics

Threads
1,109,518
Messages
5,529,314
Members
409,862
Latest member
lbisacca
Top