PDA

View Full Version : Any of you guys familiar with web query...



DanOfEarth
06-16-2010, 06:35 AM
I'm trying to do a web data-scraper using the .QueryTables method.

I did a data "web query" and ended up with this code. I was going to scrape the data onto a blank sheet and work with it from there, however this thing is already giving me an error, and I CANNOT find anything on the net to help....

Sub Query3()
'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://search.har.com/engine/doSearch.cfm?QUICKSEARCH=802%20Hallmark%20Oak" _
, Destination:=Range("Import!$A$1"))
.Name = "doSearch.cfm?QUICKSEARCH=802%20Hallmark%20Oak"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.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

If Range("A15") = "Search Result: (0) Records Found. " Then
Sheets("Leads").Range("H209").Formula = "N/A"
Sheets("Leads").Range("I209").Formula = "N/A"
End If
End Sub

It kicks it out on the first line (in red).

I've been playing with this thing for a month now. Any thoughts on this?

Thanks for listening...

mdmackillop
06-16-2010, 08:59 AM
It works for me if I have a sheet named Import. (Excel 2003)

DanOfEarth
06-16-2010, 09:38 AM
Oh man. I had that duped in two different modules...it is working. Plus I had the button on the wrong page....switched it.

Oh this thing is cool. When I'm done automating this, it'll take 40 a month hours of work down to 20 seconds.

I might need more help in the future.

FYI - Ya'll have been great . As soon as I close these deals in 30 days or so, I'm going to hit the donate button real hard....I promise you that.

This has been invaluable.:bow:

mdmackillop
06-16-2010, 03:02 PM
If only all problems were so simple!