How to Quickly Search Selected Text on Google, Yahoo and Bing in Your Word Document

In today’s article, you will learn to quickly search selected text on Google, Yahoo and Bing in your Word document without triggering browser.

Now and then, we will have to search for a lot of information online while drafting a document. In case you may feel it’s such a trouble to switch between browser window and Word document, we now offer you a way to search selected text in Word without triggering browser manually. The only things you need to do are select text and click a button.Search Selected Text on Google, Yahoo and Bing in Your Word Document

Search Selected Text on Google

  1. To begin with, trigger VBA editor by pressing “Alt+ F11”.
  2. Next create a new module by clicking “Normal” then the “Insert” tab.
  3. Then choose “Module” on the menu.Click "Normal"->Click "Insert"->Click "Module"
  4. Open the module with double click and paste the following codes there:
Sub OpenBrowser(strAddress As String, Menubar As Boolean, nHeight As Long, nWidth As Long, varResizable As Boolean)
  Dim objIE As Object
 
  '  Create and set the object settings.
  Set objIE = CreateObject("InternetExplorer.Application")
 
  With objIE
    .Visible = False
    .width = nWidth
    .height = nHeight
    .Menubar = Menubar
    .Visible = True
    .resizable = varResizable
    .Navigate strAddress
  End With

End Sub

Sub SearchOnGoogle()
  Dim strText As String
  Dim strButtonValue As String
 
  strButtonValue = MsgBox("Do you want to search the selected text on Google?", vbYesNo, "Search on Google")
    If strButtonValue = vbNo Then
      Exit Sub
    Else
      '  Make sure there is text selected.
      If Selection.Type <> wdSelectionIP Then
        strText = Selection.text
        strText = Trim(strText)
      Else
        MsgBox ("Please select text first!")
        Exit Sub
      End If
 
      '  Search selected text on Google with browser window opened in set size.
      OpenBrowser "https://www.google.com/search?num=20&hl=en&q=" & strText, True, 550, 650, True
    End If
End Sub
  1. Now click “Save”.Paste Codes->Click "Save"
  2. Next go to assign a button for the macro and add it to the “Quick Access Toolbar” for later use. So you need click “File” then “Options” to open “Word Options” box.
  3. Then select “Quick Access Toolbar” and on the right side area, choose “Macros” for command category.
  4. Find and select “SearchOnGoogle” macro.
  5. Click “Add” and click “OK”.Click "Quick Access Toolbar"->Choose "Macros"->Select the Target Macro->Click "Add"->Click "OK"
  6. Now select a text and click the macro button just added to the “Quick Access Toolbar”.
  7. There will be a confirmation message. Click “Yes” to proceed.Select Text->Click Macro Button->Click "Yes"

Then you will see a browser window open in a set size. Certainly, you can adjust its size.Browser Window Open

Search Selected Text on Yahoo

Different people prefer different browsers. Here is how you can search selected text on Yahoo.

You just need to replace macro “SearchOnGoogle” with this one:

Sub SearchOnYahoo()
  Dim strText As String
  Dim strButtonValue As String
 
  strButtonValue = MsgBox("Do you want to search the selected text on Yahoo?", vbYesNo, "Search on Yahoo")
  If strButtonValue = vbNo Then
    Exit Sub
  Else
    '  Make sure there is text selected.
    If Selection.Type <> wdSelectionIP Then
      strText = Selection.text
      strText = Trim(strText)
    Else
      MsgBox ("Please select text first!")
      Exit Sub
    End If
 
    '  Search selected text on Yahoo with browser window opened in set size.
    OpenBrowser "https://search.yahoo.com/search;?p=" & strText, True, 550, 650, True
  End If
End Sub

Then use the same steps above to install, save, and run a macro. It’s advisable to assign a button for the macro.

Search Selected Text on Bing

Here is the macro for searching on Bing:

Sub SearchOnBing()
  Dim strText As String
  Dim strButtonValue As String
 
  strButtonValue = MsgBox("Do you want to search the selected text on Bing?", vbYesNo, "Search on Bing")
  If strButtonValue = vbNo Then
    Exit Sub
  Else
    '  Make sure there is text selected.
    If Selection.Type <> wdSelectionIP Then
      strText = Selection.text
      strText = Trim(strText)
    Else
      MsgBox ("Please select text first!")
      Exit Sub
    End If
 
    '  Search selected text on Bing with browser window opened in set size.
    OpenBrowser "https://www.bing.com/search?q=" & strText, True, 550, 650, True
  End If
End Sub

Coolly Deal with Document Problems

We will by no means be panic and get frustrated once we find our documents broken. However, disappointment can get you nowhere. Instead, you should resort to a tool to repair Word and prevent from losing data forever.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xls fix and pdf repair software products. For more information visit www.datanumen.com