Starting a google search....

J

jokobe

I use this code to start a google search from a word document:

ActiveDocument.FollowHyperlink ("http://www.google.de/search?hl=de&q= " &
MySearch & " &btnG=Google-Suche&meta=")

It works fine, but I want to have quotationmarks to have an exact word for
word search.

Any helpful hints?

jokobe
 
S

StevenM

To: Jokobe,

You can add quotation marks like so:

.... & Chr(34) & MySearch & Chr(34) & etc.

Where Chr(34) = a quotation mark

Steven Craig Miller
 
J

jokobe

I have found the solution, it works like this:

MySearch = Selection.Text
strSearch = Replace(MySearch, " ", "+")
ActiveDocument.FollowHyperlink ("http://www.google.de/search?hl=de&q= " &
Chr(34) & Chr(34) & Chr(34) & strSearch & Chr(34) & Chr(34) & Chr(34) & "
&btnG=Google-Suche&meta=")

So it is 3 quotationsmarks and the spaces have to be replaced...
(there might be a smarter solution, but this works)

Anyhow, thanks for your help

jokobe
 
S

StevenM

To: jokobe,

Also, this works:

Sub TestFollowHyperlink()
Dim sSearch As String
sSearch = "Search This"
sSearch = Replace(sSearch, " ", "+")
sSearch = "%22" & sSearch & "%22"
ActiveDocument.FollowHyperlink ("http://www.google.com/search?hl=en&q="
& sSearch & "&btnG=Search")
End Sub

Google used "%22" for quotations marks.
 

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