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.Range) 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 -
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.general
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:
--
Regards,
Jay Freedman
Microsoft Word MVP Word MVP FAQ site: http://www.mvps.org/word
- Hide quoted text -
- Show quoted text -
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.Range) 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.general
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 -