Problem using oIE.Navigate to grab data from a webpage... it loads in firefox, not in VBA

Posted on 2008-11-07
Last Modified: 2012-05-05
I have a function that has been working fine.  But I had a system crash and had to do some re-installs and am now having problems.

My system has Internet Explorer and FireFox.  Firefox is my default browser and was before the crash. The function is shown in the code snippet, and it used to work fine, using the InternetExplorer object to grab the text on the given webpage and put it in a string.  But now, when the oIE.Navigate HTTPFileName is executed, it opens the page in Firefox and then it just hangs in the Do Until oIE.ReadyState = READYSTATE_COMPLETE loop, never coming out of it.

I must have some flag somewhere set wrong.

Any suggestions???



Function GetHTTPFile(ByVal HTTPFileName As String, ByVal FullDiskFileName As String, ByVal iFileNum As Integer) As Boolean

    'This requires the Microsoft Internet Controls object reference

    Dim oIE As SHDocVw.InternetExplorer

    Dim sPage As String

    Dim sSymbol As String

    Dim iStart As Long, iEnd As Long

    Dim iRow As Long

    Dim lXMPLoc As Long

    Dim lPRELoc As Long


    Set oIE = New SHDocVw.InternetExplorer

    oIE.Navigate HTTPFileName

    Do Until oIE.ReadyState = READYSTATE_COMPLETE





    sPage = oIE.Document.body.InnerHTML


    If InStr(sPage, "error") Then

        GetHTTPFile = False

    End If

    'Debug.Print sPage

    Debug.Print Left(sPage, 500)


    lXMPLoc = InStr(sPage, "<XMP>")

    If lXMPLoc > 0 Then

        sPage = Mid(sPage, lXMPLoc + Len("<XMP>")) ' was +1 after len

    End If

    Debug.Print Left(sPage, 500)

    lXMPLoc = InStr(sPage, "</XMP>")

    If lXMPLoc > 0 Then

        sPage = Left(sPage, lXMPLoc - 1)

    End If

    lPRELoc = InStr(sPage, "<PRE>")

    If lPRELoc > 0 Then

        sPage = Mid(sPage, lPRELoc + Len("<PRE>"))  ' was +1 after len

    End If

    lPRELoc = InStr(sPage, "</PRE>")

    If lPRELoc > 0 Then

        sPage = Left(sPage, lPRELoc - 1)

    End If

    Open FullDiskFileName For Output As iFileNum

    Print #iFileNum, sPage

    Close iFileNum



    GetHTTPFile = True



    Set oIE = Nothing

End Function

Open in new window

Question by:cashonly
    LVL 85

    Expert Comment

    by:Rory Archibald
    As a matter of interest does IE itself work OK - in other words if you open IE and type an address in its address bar and press enter, does it open in IE or in Firefox?

    Author Comment


    It does NOT!

    You're on to something there!
    LVL 85

    Accepted Solution

    It might be related to this issue then:

    Author Closing Comment

    You da man!
    I can only imagine the hell you went thru to find that before I asked my question!
    LVL 85

    Expert Comment

    by:Rory Archibald
    The joys of an IE beta... :) (and yet I keep doing it!)

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
    The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now