I am trying to parse a webpage but am having difficulty in getting the information coming through.
I have a simple button which navigate to a website in a worksheet
Private Sub Sellit_Click()
Dim IE As Object
Dim HTMLDoc As HTMLDocument
Dim oHTML_Element As IHTMLElement
Set IE = CreateObject("Internetexplorer.Application")
IE.Visible = True
apiShowWindow IE.hwnd, SW_MAXIMIZE
IE.navigate "https://www.yahoo.com/"
Do
Loop Until IE.ReadyState = READYSTATE_COMPLETE
DoEvents
Scrape
End Sub
While the function Scrape in a module
Function Scrape()
Dim IE As Object
Dim HTMLDoc As HTMLDocument
Dim oHTML_Element As IHTMLElement
MsgBox IE.document.Title
End Function
I kinda think i know the problem here is the IE doesn't go from the worksheet to the module and vise versa but am not quite sure how to fix it.
your help will be much apperciated
IE.ReadyStatenever equalREADYSTATE_COMPLETE? IsScrape()called? Within Scrape you never bindIE,HTMLDocoroHTML_Elementto anything.Scrapebut my question was is the macro executing that far or is it getting hung up in the loop. The second part of my previous comment still is true,IEis never set to anything withinScrape.IEinScrapeis not the same asIEinSellit_Click. The Dim Keyword redimensions it in memory at a different location. You can eithier passIE, rebindIE, or use a global varriable forIEVarriable Scope is important here.