[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-11-07
5
Medium Priority
?
593 Views
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???

Thx,

Cash

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
        DoEvents
        'Stop
    Loop
  
    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
    
    oIE.Quit
    Set oIE = Nothing
 
End Function

Open in new window

0
Comment
Question by:cashonly
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 22905324
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?
0
 

Author Comment

by:cashonly
ID: 22905455
Aha!!!

It does NOT!

You're on to something there!
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 22905530
It might be related to this issue then: http://kb.mozillazine.org/Addresses_entered_in_IE_open_in_Firefox
 
0
 

Author Closing Comment

by:cashonly
ID: 31514422
You da man!
I can only imagine the hell you went thru to find that before I asked my question!
0
 
LVL 85

Expert Comment

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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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