Hi all! Long time no see
So here is my question: Is it possible to write a VBA code to
1. Copy a description from a cell to browser
2. Search on Google images.
3. Download the first three images and place them in neighboring cells to that description. (A1: Baby Potatoes; A2: Image of Baby Potatoes; A3: 2nd Image of Baby Potatoes; A4: 3rd Image of Baby Potatoes)
It is basically an automatic image finder for a catalog =)
P.S. or is there a program to do that already in existence?
Cheerio!
Update:
Here is what i got so far:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'search google providing the selected range
Call GoogleSearch(Target)
End Sub
Module holds the search code so that it can be used by other worksheets
'list of constants
Const GOOGLE_SEARCH_URL As String = "http://images.google.com/images?q="
Public Sub GoogleSearch(ByRef Target As Range)
Dim sGoogleSearchURL As String
Dim oIE As Object
'restrict to particular column and only one cell selected
If Target.Column = 1 And Target.Cells.Count = 1 Then
'check if the cell is populate with some text
If Len(Trim(Target.Value)) > 0 Then
'create IE new window
Set oIE = CreateObject("InternetExplorer.Application")
'set IE to be visiable
oIE.Visible = True
'go to Google URL
oIE.Navigate GOOGLE_SEARCH_URL & Trim(Target.Value)
End If
End If
End Sub
Update 2:
Image insert:
Sub AddImage()
Dim thePix As Shape
Dim imageURL As String
Dim wks As Worksheet
Dim pasteBelowCell As Range
Set wks = ThisWorkbook.Sheets(1)
Set pasteBelowCell = wks.Range("D8")
imageURL = "http://www.gap.com/resources/productImage/v1/770868002/
P01"
For Each thePix In wks.Shapes
thePix.Delete
Next thePix
Set thePix = wks.Shapes.AddShape(msoShapeRectangle,
pasteBelowCell.Offset(2).Left, _
pasteBelowCell.Offset(2).Top, 120, 140)
Application.DisplayAlerts = False
On Error Resume Next
thePix.Fill.UserPicture imageURL
On Error GoTo 0
Application.DisplayAlerts = True
End Sub
Now, how to merge the two codes..
Bookmarks