Click to See Complete Forum and Search --> : can i do this?


January 27th, 2000, 01:42 PM
can i open internet explorer, go to a particular website, selectall the text from that page, and put it into an excel file?
please help.

Johnny101
January 27th, 2000, 02:51 PM
I don't know how you would format the text to get it into Excel, but here is the code to get the text...

option Explicit
Dim htmBody as new HTMLBody
Dim htmDoc as new HTMLDocument

private Sub Form_DblClick()
set htmDoc = wbcMain.Document
set htmBody = htmDoc.body
MsgBox htmBody.innerText
End Sub

private Sub Form_Load()
wbcMain.Navigate "http://www.stlvbug.org"
End Sub





You would place as web browser control on the form and name it wbcMain. To get this control, select the Microsoft Internet Controls from the list in Components.

Hope this helps,
John

John Pirkey
MCSD
www.ShallowWaterSystems.com

January 28th, 2000, 08:03 AM
thank you. i dont want to format it. i'll try this one and get back to you if i have any doubt.

January 31st, 2000, 02:59 PM
where do i place this code? how do i open excel to enter the data into it?

Johnny101
January 31st, 2000, 03:25 PM
Well, i assume that the application would have some way of specifying what website to go to. Then on that form, i guess, there would be a text box (lets call it txtURL). Once the user has entered the url into the text, they would click a button to start this process. You would have the navigate method in the click event:

private Sub cmdGo_Click()
wbcMain.Navigate txtURL.Text
'wait for the page to finish loading...
While wbcMain.Busy
DoEvents
Wend
'get the document object and then the body object
'then you can get the innerText of the body
End Sub



As for getting this text into Excel, you can reference the Excel Object Library in the references box and use Excel's object hierarchy to navigate to a worksheet object and then assign the text to a cell, or do whatever you wanted to it. You can find great help on the excel object library by looking the Excel help file under Visual Basic reference. This will tell you all about how to use the excel object in VB.

Good Luck,
John

John Pirkey
MCSD
www.ShallowWaterSystems.com