Google search for word

G

Geoff

I would like to do a Google search for an Ops Guide in Word. The
document is all text, no form fields. I have searched this forum and
the best I can find is a repost below. Is is possible to modify this
code with an input box to store the search variable and run a modifed
version below? Jay? I've tried to modify this code but was
unsucessful.

Thanks,

Geoff


start google search from formfield content?
All 3 messages in topic - view as tree
Gordon Filby May 28 2003, 2:54 am show options

Newsgroups: microsoft.public.word.vba.general
From: "Gordon Filby" <[email protected]> - Find messages by this
author
Date: Wed, 28 May 2003 09:51:53 +0200
Local: Wed, May 28 2003 2:51 am
Subject: start google search from formfield content?
Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse

Hi,


I would like to open a document containing a number of formfields,
select
one of them and use its contents as parameters for a Google search. All
this
should happen via a mouse on a button located on a command bar. Is
this
possible?


Thanks for any tips.


Gordon Filby



Jay Freedman May 28 2003, 11:40 am show options

Newsgroups: microsoft.public.word.vba.general
From: "Jay Freedman" <[email protected]> - Find messages by this
author
Date: Wed, 28 May 2003 12:37:38 -0400
Local: Wed, May 28 2003 11:37 am
Subject: Re: start google search from formfield content?
Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse

Hi, Gordon,


This might be a bit over-engineered :) but it does work. Put the macro
into
your template, and assign a toolbar button to run the macro. It will
fire a
Google search for the contents of whatever formfield has the focus.


Sub GoogleIt()
Dim SearchTerms As String
Dim oFld As FormField
Dim oHyper As Hyperlink
On Error GoTo badfield
For Each oFld In ActiveDocument.FormFields
If Selection.Range.InRange(oFld.R­ange) Then
SearchTerms = oFld.Result
Exit For
End If
Next oFld
If SearchTerms <> "" Then
Set oHyper = ActiveDocument.Hyperlinks.Add( _
Anchor:=ActiveDocument.Range, _
Address:="http://www.google.com/search?q=" & SearchTerms)
oHyper.Follow
oHyper.Delete
End If
badfield:
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP Word MVP FAQ site: http://www.mvps.org/word



- Hide quoted text -
- Show quoted text -

Gordon said:
I would like to open a document containing a number of formfields,
select one of them and use its contents as parameters for a Google
search. All this should happen via a mouse on a button located on a
command bar. Is this possible?

Thanks for any tips.

Gordon Filby




Jay Freedman Jun 2 2003, 11:16 am show options

Newsgroups: microsoft.public.word.vba.general
From: "Jay Freedman" <[email protected]> - Find messages by this
author
Date: Mon, 2 Jun 2003 12:15:36 -0400
Local: Mon, Jun 2 2003 11:15 am
Subject: Re: start google search from formfield content?
Reply to Author | Forward | Print | Individual Message | Show original
| Report Abuse

[replied and posted to the microsoft.public.word.vba.gene­ral
newsgroup]


To find only German language pages, change the Address parameter of the

hyperlink this way:


Address:="http://www.google.com/search?q=" _
& SearchTerms & "&lr=lang_de")


Gordon Filby wrote by email:


Thanks - that is just what I needed. Another question in this context in
Address:="http://www.google.com/search?q=" & SearchTerms) do you
know how to restrict the search only to German language pages. Google
allows this in its special config. page.


--
Regards,
Jay Freedman
Microsoft Word MVP Word MVP FAQ site: http://www.mvps.org/word


- Hide quoted text -
- Show quoted text -
 
J

Jay Freedman

Hi Geoff,

Yes, it's possible. The macro breaks naturally into two parts: (1) get the
term to search for, then (2) create and launch the hyperlink to Google. What
you want is to replace the first part, so that instead of looking for a
field result, you use an input box.

Sub GoogleIt()
Dim SearchTerms As String
Dim oHyper As Hyperlink

SearchTerms = InputBox$("Enter the search terms", "Google It")

If SearchTerms <> "" Then
Set oHyper = ActiveDocument.Hyperlinks.Add( _
Anchor:=ActiveDocument.Range, _
Address:="http://www.google.com/search?q=" & SearchTerms)
oHyper.Follow
oHyper.Delete
End If
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
I would like to do a Google search for an Ops Guide in Word. The
document is all text, no form fields. I have searched this forum and
the best I can find is a repost below. Is is possible to modify this
code with an input box to store the search variable and run a modifed
version below? Jay? I've tried to modify this code but was
unsucessful.

Thanks,

Geoff


start google search from formfield content?
All 3 messages in topic - view as tree
Gordon Filby May 28 2003, 2:54 am show options

Newsgroups: microsoft.public.word.vba.general
From: "Gordon Filby" <[email protected]> - Find messages by this
author
Date: Wed, 28 May 2003 09:51:53 +0200
Local: Wed, May 28 2003 2:51 am
Subject: start google search from formfield content?
Reply to Author | Forward | Print | Individual Message | Show original
Report Abuse

Hi,


I would like to open a document containing a number of formfields,
select
one of them and use its contents as parameters for a Google search.
All this
should happen via a mouse on a button located on a command bar. Is
this
possible?


Thanks for any tips.


Gordon Filby



Jay Freedman May 28 2003, 11:40 am show options

Newsgroups: microsoft.public.word.vba.general
From: "Jay Freedman" <[email protected]> - Find messages by
this author
Date: Wed, 28 May 2003 12:37:38 -0400
Local: Wed, May 28 2003 11:37 am
Subject: Re: start google search from formfield content?
Reply to Author | Forward | Print | Individual Message | Show original
Report Abuse

Hi, Gordon,


This might be a bit over-engineered :) but it does work. Put the
macro into
your template, and assign a toolbar button to run the macro. It will
fire a
Google search for the contents of whatever formfield has the focus.


Sub GoogleIt()
Dim SearchTerms As String
Dim oFld As FormField
Dim oHyper As Hyperlink
On Error GoTo badfield
For Each oFld In ActiveDocument.FormFields
If Selection.Range.InRange(oFld.R­ange) Then
SearchTerms = oFld.Result
Exit For
End If
Next oFld
If SearchTerms <> "" Then
Set oHyper = ActiveDocument.Hyperlinks.Add( _
Anchor:=ActiveDocument.Range, _
Address:="http://www.google.com/search?q=" & SearchTerms)
oHyper.Follow
oHyper.Delete
End If
badfield:
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP Word MVP FAQ site: http://www.mvps.org/word



- Hide quoted text -
- Show quoted text -

Gordon said:
I would like to open a document containing a number of formfields,
select one of them and use its contents as parameters for a Google
search. All this should happen via a mouse on a button located on a
command bar. Is this possible?

Thanks for any tips.

Gordon Filby




Jay Freedman Jun 2 2003, 11:16 am show options

Newsgroups: microsoft.public.word.vba.general
From: "Jay Freedman" <[email protected]> - Find messages by
this author
Date: Mon, 2 Jun 2003 12:15:36 -0400
Local: Mon, Jun 2 2003 11:15 am
Subject: Re: start google search from formfield content?
Reply to Author | Forward | Print | Individual Message | Show original
Report Abuse

[replied and posted to the microsoft.public.word.vba.gene­ral
newsgroup]


To find only German language pages, change the Address parameter of
the

hyperlink this way:


Address:="http://www.google.com/search?q=" _
& SearchTerms & "&lr=lang_de")


Gordon Filby wrote by email:


Thanks - that is just what I needed. Another question in this
context in Address:="http://www.google.com/search?q=" & SearchTerms)
do you know how to restrict the search only to German language
pages. Google allows this in its special config. page.
 
G

Geoff

Hi Jay,

Thanks for the quick response. The code did work, but it googled the
web. Is it possible to google my document based on search criteria.
What I want to do is have a search feature that lists all hits for a
given criteria. The search feature in Word is just too limited. I
thought Google ( or something like it) would be perfect.

Any thoughts?

Geoff
 
J

Jay Freedman

Geoff said:
Hi Jay,

Thanks for the quick response. The code did work, but it googled the
web. Is it possible to google my document based on search criteria.
What I want to do is have a search feature that lists all hits for a
given criteria. The search feature in Word is just too limited. I
thought Google ( or something like it) would be perfect.

Any thoughts?

Geoff

No. This technique, using a URL, requires a web server. Unless you're
running a server on your local machine, nothing even remotely like this is
going to work.

Have you tried Google Desktop
(http://desktop.google.com/?promo=mp-gds-v1-1)?
 
J

Jay Freedman

Geoff said:
Hi Jay,

Thanks for the quick response. The code did work, but it googled the
web. Is it possible to google my document based on search criteria.
What I want to do is have a search feature that lists all hits for a
given criteria. The search feature in Word is just too limited. I
thought Google ( or something like it) would be perfect.

Any thoughts?

Geoff

OK, maybe it's the way you write or the way I read, but it occurred to me
that we're probably still not on the same wavelength. My suggestion of
Google Desktop came from the thought that you were trying to find closed
documents in unknown locations on your local drive. When I reread your
original post, though, I see something else.

Do you mean that you have a document open in Word, and you want to see a
list of all the hits for a given search term *within that document* instead
of going to them one at a time? If so, Google is the wrong model -- you want
a search dialog like the one in Adobe Reader. I just happen to have one of
those. :)

Download "finder" from http://jay-freedman.info and see if that suits your
needs.
 
G

Geoff

Hi Jay,

Thanks for the info. After my initial euphoria, it hit me that I left
out some important facts. Your finder.dot worked very nicely in Word.
What I left out from my original post was that I am converting this
large document to html for viewing through IE, hence my desire for a
Google search engine. I've looked at Googles desktop version but that
doesn't seem to search within html "docs".

So let me take a step back and try and summarize what I am trying to
do. I have a number of chapters (individual docs) that are combined
into an Ops Guide.
From there I am coverting into *.pdf for printing and html for web
browsing. Since the guide is extensive (600 pages) I thought it would
be a great idea to provide a command button that would launch a "Google
like" search engine to view content within this single doc/web view.

Your applet worked nice in Word, but I realized that this would not
work in IE. Is what I am looking for beyond the scope of this forum?
Maybe so, but isn't there some kind of search engine like Google
available for what I am trying to do?

Jay, thanks again for your input!
 
J

Jay Freedman

Hi Geoff,

Yes, what you want to do is outside the scope of this newsgroup. Once
your document leaves the confines of Word, the tools and methods are
quite different.

I don't have any personal knowledge of what's involved, but you can
find what you want at http://www.google.com/enterprise/.
 

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