|
-
January 27th, 2000, 02:42 PM
#1
can i do this?
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.
-
January 27th, 2000, 03:51 PM
#2
Re: can i do this?
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
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
January 28th, 2000, 09:03 AM
#3
Re: can i do this?
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, 03:59 PM
#4
Re: can i do this?
where do i place this code? how do i open excel to enter the data into it?
-
January 31st, 2000, 04:25 PM
#5
Re: can i do this?
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
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|