• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 610
  • Last Modified:

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

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

  • 3
  • 2
1 Solution
Rory ArchibaldCommented:
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?
cashonlyAuthor Commented:

It does NOT!

You're on to something there!
Rory ArchibaldCommented:
It might be related to this issue then: http://kb.mozillazine.org/Addresses_entered_in_IE_open_in_Firefox
cashonlyAuthor Commented:
You da man!
I can only imagine the hell you went thru to find that before I asked my question!
Rory ArchibaldCommented:
The joys of an IE beta... :) (and yet I keep doing it!)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now