Thursday, September 22, 2011

Search selected cell from excel using your favorite browser and search engine

This macro will help you to search with the content of the selected cell from word doc directly in google or any other site easily.
Simply select the text and run the macro your search result will appear in your favorite browser.
Note:
1.Change the Path to your browser (firefox, IE, chrome etc.,) installation path.
2.To search other website change the Link to your favorite search engine.
3.Select only single cell.

Code:
*********************************************************************
Sub googlesearch()

Dim x As Variant
Dim Path As String
Dim Link As String
Dim TheTerm As String

TheTerm = excel.selection

    Path = "C:\Program Files\Mozilla Firefox\firefox.exe"

    'for internet explorer change the path to "C:\Program Files\Internet Explorer\iexplore.exe"

    Link = "http://www.google.com/search?num=20&hl=en&q=" & TheTerm
    'for searching with Bing change the Link to "http://www.bing.com/search?q="

    x = Shell(Path + " " + Link, vbNormalFocus)

End Sub
*********************************************************************

No comments:

Post a Comment