Ross,
Here is a barebones example to return the first result from a Google search in Excel using the google API.
In order for the code to work you need to download the appropriate Soap toolkit, and follow the directions for loading the WDSL. You can find the Google WSDL here.
I’ve tested the code with the 2003 toolkit and it works fine. You may need to tweak it some with the 2002, not sure.
Also, keep in mind that the google API returns html formatted results. Maybe Dick has a solution for that?
You’ll need to add your google developer key to the code also:
Sub MyGoogleSearch()
Dim GoogleSearch As New clsws_GoogleSearchService
Dim GStruct As struct_GoogleSearchResult
Dim GoogleKey As String
Dim GoogleSearchWord As String
GoogleSearchWord = "Excel"
GoogleKey = ""
Set GStruct = GoogleSearch.wsm_doGoogleSearch _
(GoogleKey, GoogleSearchWord, 0, 1, True, "", _
True, "", "utf8", "utf8")
Sheet1.Cells(1, 1) = GStruct.resultElements(0).title
Sheet1.Cells(2, 1) = GStruct.resultElements(0).snippet
Sheet1.Cells(3, 1) = GStruct.resultElements(0).URL
End Sub
Note: I’m sure you could finger it out yourself in 10 minutes, but I thought I’d save you (or others) the time ![]()
June 13th, 2005 at 12:53 pm
thank Mark!!!
I played around with the google API’s, i tryed using the old site:www.soandso.com Monkeis, but it didn’t return good results for the site (yell.com) i was targetting. I might bang something to getaher that “puts”+”all the”+”bits of some”+”cells togther” like this and send the query, but i’m not sure how usefull that would be - maybe i could display the results in the active x web broswer on a form?
thanks agian mark - it worked perfectly btw.
Mark!
June 13th, 2005 at 4:34 pm
no problem, glad it worked.
umm I downloaded your drawing on a form, neat stuff, is there a reason it’s password protected?
June 14th, 2005 at 1:13 am
just to stop the objects expanding in the list viwe in the VBE, the password is methodsinexcel, or mie, i think. I just don’t like all the projects being unfolded!