Hello e4excel,
I did some more reading on the Explorer code and I believe that this code will work through Internet Explorer 7. I added to your drop down list. You can search by Google or Alibaba. The macro will open a new tab in the same window. The drop down also includes "Suppliers" and "Manufacturers". Even if this code doesn't run, it will still be a good template to draw from.
Sheet2 Worksheet_Change() Event Code
Private Sub Worksheet_Change(ByVal Target As Range)
Dim I As Long
Dim SearchTerms As String
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("C2:C" & Rows.Count)) Is Nothing Then
SearchTerms = Target.Offset(0, -1).Text
I = InStr(1, Target, "+")
If I Then SearchTerms = SearchTerms & " " & Right(Target, Len(Target) - I)
Select Case Target.Text
Case Is = "Search Google", "Search Google + Suppliers", "Search Google + Manufacturers"
InternetSearch SearchTerms, "www.google.com"
Case Is = "Search Alibaba", "Search Alibaba + Suppliers", "Search Alibaba + Manufacturers"
InternetSearch SearchTerms, "www.alibaba.com"
End Select
End If
End Sub
Module Macro Code
Public ieApp As Object
Sub InternetSearch(ByVal SearchTerm As String, ByVal SearchEngine As String)
Dim ieDoc As Object
Dim InputBox As Object
Dim SearchButton As Object
Dim URL As String
If TypeName(ieApp) = "Object" Or TypeName(ieApp) = "Nothing" Then
Set ieApp = CreateObject("InternetExplorer.Application")
ieApp.Visible = True
GoSub OpenNewTab
End If
Set ieDoc = ieApp.Document
If ieDoc.Domain <> "" And ieDoc.Domain <> SearchEngine Then GoSub OpenNewTab
Select Case ieDoc.Domain
Case Is = "www.google.com"
Set InputBox = ieDoc.getElementsByName("q")
Set SearchButton = ieDoc.getElementsByName("btnG")
InputBox.Item(0).Value = SearchTerm
SearchButton.Item(0).Click
Case Is = "alibaba.com"
Set InputBox = ieDoc.getElementById("SearchTextIdx")
Set SearchButton = ieDoc.getElementById("searchSubmit")
InputBox.Value = SearchTerm
SearchButton.Click
End Select
Set ieDoc = Nothing
Exit Sub
OpenNewTab:
While ieApp.Busy
DoEvents
Wend
ieApp.Navigate SearchEngine, 2048
While ieApp.Busy
DoEvents
Wend
Return
End Sub
Bookmarks