• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

[QueryTables] - extract content as raw html

geniux

New Member
Greetings to all VBA Guru's! ;)

I'm running into a problem when extracting content from an web url and importing it to my excelsheet. I use the following macro to extract the webcontent, but it imports the content as plain text:

Code:
Sub WebData()

Dim wSU As Worksheet
Dim wSR As Worksheet
Dim wSS As Worksheet

Dim iForRow As Integer
Dim iLastRow As Integer
Dim sURL As String

Set wSU = ThisWorkbook.Sheets("URLs")
Set wSR = ThisWorkbook.Sheets("Results")
Set wSS = ThisWorkbook.Sheets("Scrape")

Application.ScreenUpdating = False
iLastRow = wSU.Cells(wSU.Rows.Count, "a").End(xlUp).Row
For iForRow = 1 To iLastRow Step 1
sURL$ = wSU.Cells(iForRow, "a").Value
With wSS.QueryTables.Add(Connection:= _
"URL;" & sURL, Destination:=wSS.Range("A1"))
.Name = _
"example.aspx"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
wSR.Cells(iForRow + 1, "a").Value = "<h4>" + wSS.Range("A3").Value + "</h4>"


Next iForRow
Application.ScreenUpdating = True
MsgBox "Process Completed"
End Sub

So my question is: How can I import the content as raw HTML, putting everything in one cell instead of filling up the "Scrape" sheet with plain text and seperate columns?

Thanks!
 
Hi Marc! Thanks for your quick response and usefull link, i'm looking in to it and will report back :)
 
Back
Top