dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Beginner
May 19, 2004

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date