Word macro for Google search
Thread poster: Samuel Murray
Samuel Murray
Samuel Murray  Identity Verified
Netherlands
Local time: 13:25
Member (2006)
English to Afrikaans
+ ...
Jul 3, 2019

Hello everyone

Does anyone know of a Word macro that can be used to send the currently selected text to the browser as a Google search? I'm looking specifically for a Word macro and not for e.g. an AU3 or AHK script.

Thanks
Samuel

==


 
wotswot
wotswot  Identity Verified
France
Local time: 13:25
Member (2011)
French to English
Here's the code you need Jul 3, 2019

Create a module in VBA (in a .dotm file or your normal.dot(m), if you have one)
In the new module, copy everything below the dotted line exactly as is.
(You may want to localize the google url)
Select some text in Word
Run the macro (only tested in Windows 7)
-------------------------------------------------

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As Strin
... See more
Create a module in VBA (in a .dotm file or your normal.dot(m), if you have one)
In the new module, copy everything below the dotted line exactly as is.
(You may want to localize the google url)
Select some text in Word
Run the macro (only tested in Windows 7)
-------------------------------------------------

Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Sub GoogleSearch() 'You can assign this macro to a function key if you want
Dim T As String
If Len(Trim(Selection.Text)) > 1 Then 'There must be some text selected in Word
T = Selection.Text
T = Replace(T, " ", "+") 'Words in the query's text must be separated by '+'
OpenURL "http://www.google.com/search?as_epq=" & T 'the as_epq parameter means results must include the query,
'in the word order displayed.
'see the link below for a full list of google search URL parameters
'https://moz.com/blog/the-ultimate-guide-to-the-google-search-parameters
End If
End Sub

Private Function OpenURL(ByVal URLString As String)
ShellExecute 0, "open", URLString, 0, 0, 1
End Function
Collapse


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Word macro for Google search






Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »
Trados Business Manager Lite
Create customer quotes and invoices from within Trados Studio

Trados Business Manager Lite helps to simplify and speed up some of the daily tasks, such as invoicing and reporting, associated with running your freelance translation business.

More info »