advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
advertisement
Tip of the Day
Average Rating: 5/5 | Rate this item | 2 users have rated this item.
Expertise: Beginner
Language: Visual Basic
May 18, 2004
Import Web Content into Your Excel Workbook
Importing Web content into your Excel workbook is simple using Micorosoft's WinHTTP tools (they are free and included with IE).

First, create and save an Excel Workbook. Next, access the visual basic editor (ALT-F11). Insert a new module and paste the following code:


Public Sub GetPage(Optional prmURL As Variant)
    Dim WinHttpReq As WinHttp.WinHttpRequest
    Dim txtURL As Variant
        
    If IsMissing(prmURL) Or IsNull(prmURL) Or IsEmpty(prmURL) Then
        txtURL = "http://www.devx.com"
    Else
        txtURL = prmURL
    End If
    
    
    ' Create an instance of the WinHTTPRequest ActiveX object.
    Set WinHttpReq = New WinHttpRequest
    
    ' Assemble an HTTP Request.
    WinHttpReq.Open "GET", txtURL, False

    ' Send the HTTP Request.
    WinHttpReq.Send
    
    ' Put status and content type into your workbook Column 1, row 2 and 3
    ActiveSheet.Cells(2, 1) = WinHttpReq.Status & " - " & WinHttpReq.StatusText
    ActiveSheet.Cells(3, 1) = WinHttpReq.ResponseText
End Sub
Lastly, insert a Visual Basic button in your file, and have it call the procedure. For example:
 
GetPage "http://www.microsoft.com"
George Daouros
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.
Please rate this item (5=best)
 1  2  3  4  5
advertisement
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs