Search Google from Textbox

J

John

Hi there,

I've got a user form which I'm using to check against a list of names. What
I'd like to do is to assign a (Google) search to a command button, with the
search words based on the text in a textbox.

Can anyone point me in the right direction?

(The button just needs to activate Internet Explorer with Google and the
search results.)

Thanks

John
 
J

John

Hi Tom,

Thanks for this. Looks very interesting, but I was hoping to use it on my
own command button so that the user does have to type in the text that's
already there.

Any clues?

Thanks again

John
 
H

Harald Staff

Hi John

Private Sub CommandButton1_Click()
ActiveWorkbook.FollowHyperlink _
"http://www.google.com/search?hl=en&q=" & _
Replace$(Me.TextBox1.Text, " ", "+")
End Sub

Refine this coding by scrutinizing your manual Google searches' returning
url's, using quotes, domain restricted searches, ...

HTH. Best wishes Harald
 
J

John

Great. Thanks Harald, this works perfectly.

Thanks also Tom for Ron's email.

Best regards

John
 
J

John

....and for anyone who's interested the following includes some of the Google
converted symbols:

Private Sub cmdGoogle_Click()
Dim sSearchText As String
'Set search string
sSearchText = Me.lstBox1.Text
'Replace double quotes with Google equivilent
sSearchText = Replace$(sSearchText, Chr(34), "%22")
'Replace single quotes with Google equivilent
sSearchText = Replace$(sSearchText, Chr(39), "%27")
'Replace left bracket with Google equivilent
sSearchText = Replace$(sSearchText, Chr(40), "%28")
'Replace right bracket with Google equivilent
sSearchText = Replace$(sSearchText, Chr(41), "%29")
'Replace spaces with Google equivilent
sSearchText = Replace$(sSearchText, " ", "+")
ActiveWorkbook.FollowHyperlink _
"http://www.google.co.uk/search?hl=en&q=" & _
sSearchText
End Sub

Thanks again Harald and Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top