Launch browser and search from within Excel

ronti69

New Member
Joined
Aug 26, 2014
Messages
2
Hello,
Is there a way to launch a web browser from within Excel and have the browser search for the content of the cell?
Fo example, if F2=California and F3=Utah, can I create buttons in G2 and G3 such that when I click one of them it launches the web browser, goes to Google and searches for "California", or "Utah"?

I can hyperlink F2 to google.com but I don't know how to add the content of the cell to the hyperlink

By the way I am using Excel for Mac if that matters

Thanks!!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Not to familiar with ie Automation VBA but this will get you part of the way to your goal. Not sure how to "Click" the Search Button.
Make sure to add the correct references. While in the VBE go to Tools > References > Then Select Microsoft HTML Object Library & Microsoft Internet Controls.

Code:
[COLOR=#0000ff]Sub[/COLOR] IE_FindTest()
   
[COLOR=#008000]     'make sure you add references to Microsoft Internet Controls (shdocvw.dll) and[/COLOR]
[COLOR=#008000]     'Microsoft HTML object Library.[/COLOR]
[COLOR=#008000]     'Code will NOT run otherwise.[/COLOR]
   
    [COLOR=#0000ff]Dim[/COLOR] objIE[COLOR=#0000ff] As[/COLOR] SHDocVw.InternetExplorer [COLOR=#008000]'microsoft internet controls (shdocvw.dll)[/COLOR]
   [COLOR=#0000ff] Dim[/COLOR] htmlDoc[COLOR=#0000ff] As[/COLOR] MSHTML.HTMLDocument [COLOR=#008000]'Microsoft HTML Object Library[/COLOR]
    [COLOR=#0000ff]Dim [/COLOR]htmlInput [COLOR=#0000ff]As[/COLOR] MSHTML.HTMLInputElement
   [COLOR=#0000ff] Dim[/COLOR] htmlColl [COLOR=#0000ff]As[/COLOR] MSHTML.IHTMLElementCollection
    [COLOR=#0000ff]Dim[/COLOR] objCollection [COLOR=#0000ff]As Object[/COLOR]
   [COLOR=#0000ff] Dim[/COLOR] objElement [COLOR=#0000ff]As Object[/COLOR]
    [COLOR=#0000ff]Dim [/COLOR]i [COLOR=#0000ff]As Long[/COLOR]
     
    [COLOR=#0000ff]Set[/COLOR] objIE = New SHDocVw.InternetExplorer
     
   [COLOR=#0000ff] With [/COLOR]objIE
        .Navigate "http://www.google.com" [COLOR=#008000]' Main page[/COLOR]
        .Visible = 1
        [COLOR=#0000ff] Do While[/COLOR] .ReadyState <> 4: DoEvents: [COLOR=#0000ff]Loop[/COLOR]
            Application.Wait (Now + TimeValue("0:00:02"))
[COLOR=#0000ff]    End With[/COLOR]

    [COLOR=#0000ff]Set [/COLOR]objCollection = objIE.Document.getElementsByTagName("input")
 
    i = 0
   [COLOR=#0000ff] While [/COLOR]i < objCollection.Length
     
[COLOR=#008000]            ' Set text for search[/COLOR]
            objCollection(i).Value =[COLOR=#ff0000] Range("F2").Value [/COLOR][COLOR=#008000]' Your Range[/COLOR]
          [COLOR=#0000ff]  Set [/COLOR]objElement = objCollection(i)
            
        i = i + 1
[COLOR=#0000ff]    Wend[/COLOR]
        
[COLOR=#008000]        'Code To Click Search Here[/COLOR]

[COLOR=#0000ff]End Sub[/COLOR]

There is most likely a better way to accomplish this task.
 
Upvote 0
Thank you mrmmickle1! I don't have the Microsoft HTML Object Library & Microsoft Internet Controls. Does it have to do with me working on a Mac? How can I get them?
I tried your code anyway but as you said it did not work...
 
Last edited:
Upvote 0
ronti69,

Not to sure since I haven't had this issue but, I found a few links to information that may help:

Here is a link for help finding Microsoft Internet Controls: CLICK LINK HERE
For the second reference (HTML Object Library) try looking for this file, not sure if it is the same thing, but I read a few things that alluded to it: [FONT=Verdana, Arial, Helvetica, sans-serif]microsoft.mshtml.dll[/FONT]

[FONT=Verdana, Arial, Helvetica, sans-serif]Hope this helps a little bit. Sorry. I don't have much experience with this kind of issue.[/FONT]
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top