CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: can i do this?

  1. #1
    Guest

    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.



  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    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

  3. #3
    Guest

    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.


  4. #4
    Guest

    Re: can i do this?

    where do i place this code? how do i open excel to enter the data into it?


  5. #5
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    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
  •  





Click Here to Expand Forum to Full Width

Featured