+ Reply to Thread
Results 1 to 2 of 2

Run-time error 91: Object viable or with block varible not set

Hybrid View

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    South Yorks, England
    MS-Off Ver
    Excel 2010
    Posts
    32

    Run-time error 91: Object viable or with block varible not set

    Hello, I want to learn VBA (hence I just arrived at this forum). I have created the following code, sometimes it works but mostly I get Error '91' please could someone tell me what I have missed out? NB, I have changed the login codes to asterix to protect privacy.
    Sub Open_Internet_Explorer()
    Dim IE As Object
     
    Set IE = CreateObject("InternetExplorer.Application")
     IE.navigate "http://tracking.phservice.co.uk/auth/login"
     IE.Visible = True
     While IE.busy
     DoEvents
       Wend
       Dim ieDoc As Object
    
    
    
    
    IE.Document.all("username").Value = "********"
     IE.Document.all("password").Value = "*******"

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Run-time error 91: Object viable or with block varible not set

    You need to wait for IE.readyState too, like this:
    Sub Open_Internet_Explorer()
    
        Dim IE As Object
        Dim IEdoc As Object
     
        Set IE = CreateObject("InternetExplorer.Application")
        With IE
            .navigate "http://tracking.phservice.co.uk/auth/login"
            .Visible = True
            While .busy Or .readystate <> 4
                DoEvents
            Wend
            .Document.all("username").Value = "********"
            .Document.all("password").Value = "********"
        End With
        
     End Sub
    Post responsibly. Search for excelforum.com

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1