31 added 6 characters in body
source | link

Full Sub routine that takes input n (short for name) of expected type Variant/String and outputs the first google image search result for the query of that name and glamour shot to the Sheets(1) objectan internet explorer window.

Full Sub routine that takes input n (short for name) of expected type Variant/String and outputs the first google image search result for the query of that name and glamour shot to the Sheets(1) object

Full Sub routine that takes input n (short for name) of expected type Variant/String and outputs the first google image search result for the query of that name and glamour shot to an internet explorer window.

30 deleted 166 characters in body
source | link

Excel VBA +, 465 463 461 437 427 419 418 415 407 395 388 382 369 367 356 348 332 Bytes

Sub g(n)
Set i=New InternetExplorer
l="google.nl/search?tbm=isch&q="&Replace(n," ","+")&"+glamour+shot"
For y=0To 2
i.navigate l
While i.readyState<4
DoEvents
Wend
j=0
Do Until InStr(1,l,IIf(y,"yp","res"))
j=j+1
Set x=i.document.getElementsByTagName(IIf(y,"img","a"))(j)
If y Then l=x.src Else l=x.href
Loop
Next
i.visible=1
End Sub
Sub g(n)
Set i=New InternetExplorer
l="google.nl/search?tbm=isch&q="&Replace(n," ","+")&"+glamour+shot"
For y=0To 2
i.navigate l
While i.readyState<4
DoEvents
Wend
j=0
Do Until InStr(1,l,IIf(y,"yp","res"))
j=j+1
Set x=i.document.getElementsByTagName(IIf(y,"img","a"))(j)
If y Then l=x.src Else l=x.href
Loop
Next
i.visible=1
End Sub
Option Private Module
Option Compare Text
Option Explicit
Option Base 0

Sub GlamourShot(ByVal name As String)

    Dim ie As New SHDocVw.InternetExplorer, _
        doc As MSHTML.HTMLDocument, _
        link As String, _
        j As Integer, _
        k As Integer

    With ie
        On Error GoTo CloseIE #'prevents memory leak

        Let .visible = True
        Call .navigate("www.google.com/search?tbm=isch&q=" & _
                    Replace(name, " ", "+") & _
                    "+glamour+shot")
        While .readyState <> READYSTATE_COMPLETE Or .Busy
            VBA.DoEvents
        Wend

        Set doc = .document

        Let j = 1
        Do Until InStr(1, link, "imgres") > 0
            Let link = doc.getElementsByTagName("a")(j).href
            Let j = j + 1
        Loop

        Call .navigate(link)
        While .readyState <> READYSTATE_COMPLETE Or .Busy
            VBA.DoEvents
        Wend

        Let k = 1
        Do Until InStr(1, link, "encrypted") > 0
            Let link = doc.getElementsByTagName("img")(k).src
            Let k = k + 1
        Loop

        With ThisWorkbook.ActiveSheet
            Call .Range("A1").Select
            Call .Pictures.Insert(link)
            Call .Activate
        End With
CloseIE:
        Call .Quit
    End With
End Sub
Option Private Module
Option Compare Text
Option Explicit
Option Base 0

Sub GlamourShot(ByVal name As String)

    Dim ie As New SHDocVw.InternetExplorer, _
        doc As MSHTML.HTMLDocument, _
        link As String, _
        j As Integer, _
        k As Integer

    With ie
        On Error GoTo CloseIE #'prevents memory leak

        Let .visible = True
        Call .navigate("www.google.com/search?tbm=isch&q=" & _
                    Replace(name, " ", "+") & _
                    "+glamour+shot")
        While .readyState <> READYSTATE_COMPLETE Or .Busy
            VBA.DoEvents
        Wend

        Set doc = .document

        Let j = 1
        Do Until InStr(1, link, "imgres") > 0
            Let link = doc.getElementsByTagName("a")(j).href
            Let j = j + 1
        Loop

        Call .navigate(link)
        While .readyState <> READYSTATE_COMPLETE Or .Busy
            VBA.DoEvents
        Wend

        Let k = 1
        Do Until InStr(1, link, "encrypted") > 0
            Let link = doc.getElementsByTagName("img")(k).src
            Let k = k + 1
        Loop

        With ThisWorkbook.ActiveSheet
            Call .Range("A1").Select
            Call .Pictures.Insert(link)
            Call .Activate
        End With
CloseIE:
        Call .Quit
    End With
End Sub

Excel VBA +, 465 463 461 437 427 419 418 415 407 395 388 382 369 367 356 348 332 Bytes

Sub g(n)
Set i=New InternetExplorer
l="google.nl/search?tbm=isch&q="&Replace(n," ","+")&"+glamour+shot"
For y=0To 2
i.navigate l
While i.readyState<4
DoEvents
Wend
j=0
Do Until InStr(1,l,IIf(y,"yp","res"))
j=j+1
Set x=i.document.getElementsByTagName(IIf(y,"img","a"))(j)
If y Then l=x.src Else l=x.href
Loop
Next
i.visible=1
End Sub
Option Private Module
Option Compare Text
Option Explicit
Option Base 0

Sub GlamourShot(ByVal name As String)

    Dim ie As New SHDocVw.InternetExplorer, _
        doc As MSHTML.HTMLDocument, _
        link As String, _
        j As Integer, _
        k As Integer

    With ie
        On Error GoTo CloseIE #'prevents memory leak

        Let .visible = True
        Call .navigate("www.google.com/search?tbm=isch&q=" & _
                    Replace(name, " ", "+") & _
                    "+glamour+shot")
        While .readyState <> READYSTATE_COMPLETE Or .Busy
            VBA.DoEvents
        Wend

        Set doc = .document

        Let j = 1
        Do Until InStr(1, link, "imgres") > 0
            Let link = doc.getElementsByTagName("a")(j).href
            Let j = j + 1
        Loop

        Call .navigate(link)
        While .readyState <> READYSTATE_COMPLETE Or .Busy
            VBA.DoEvents
        Wend

        Let k = 1
        Do Until InStr(1, link, "encrypted") > 0
            Let link = doc.getElementsByTagName("img")(k).src
            Let k = k + 1
        Loop

        With ThisWorkbook.ActiveSheet
            Call .Range("A1").Select
            Call .Pictures.Insert(link)
            Call .Activate
        End With
CloseIE:
        Call .Quit
    End With
End Sub

Excel VBA +, 465 332 Bytes

Sub g(n)
Set i=New InternetExplorer
l="google.nl/search?tbm=isch&q="&Replace(n," ","+")&"+glamour+shot"
For y=0To 2
i.navigate l
While i.readyState<4
DoEvents
Wend
j=0
Do Until InStr(1,l,IIf(y,"yp","res"))
j=j+1
Set x=i.document.getElementsByTagName(IIf(y,"img","a"))(j)
If y Then l=x.src Else l=x.href
Loop
Next
i.visible=1
End Sub
Option Private Module
Option Compare Text
Option Explicit
Option Base 0

Sub GlamourShot(ByVal name As String)

    Dim ie As New SHDocVw.InternetExplorer, _
        doc As MSHTML.HTMLDocument, _
        link As String, _
        j As Integer, _
        k As Integer

    With ie
        On Error GoTo CloseIE #'prevents memory leak

        Let .visible = True
        Call .navigate("www.google.com/search?tbm=isch&q=" & _
                    Replace(name, " ", "+") & _
                    "+glamour+shot")
        While .readyState <> READYSTATE_COMPLETE Or .Busy
            VBA.DoEvents
        Wend

        Set doc = .document

        Let j = 1
        Do Until InStr(1, link, "imgres") > 0
            Let link = doc.getElementsByTagName("a")(j).href
            Let j = j + 1
        Loop

        Call .navigate(link)
        While .readyState <> READYSTATE_COMPLETE Or .Busy
            VBA.DoEvents
        Wend

        Let k = 1
        Do Until InStr(1, link, "encrypted") > 0
            Let link = doc.getElementsByTagName("img")(k).src
            Let k = k + 1
        Loop

        With ThisWorkbook.ActiveSheet
            Call .Range("A1").Select
            Call .Pictures.Insert(link)
            Call .Activate
        End With
CloseIE:
        Call .Quit
    End With
End Sub
29 deleted 64 characters in body
source | link

Must be run in a clean module. No longer necessary.

Must be run in a clean module. No longer necessary.

28 added 22 characters in body
source | link
27 deleted 1 character in body
source | link
26 +3 Optimism
source | link
25 condensed method
source | link
24 added 1 character in body
source | link
23 I can count - i swear
source | link
22 label loop
source | link
21 Class call
source | link
20 immediate window function
source | link
19 condensing
source | link
18 Expanded helper Sub
source | link
17 moved `i.navigate` into `h(i,l)`
source | link
16 removed `i.quit`
source | link
15 Byte Count, ungolfed
source | link
14 visible IE
source | link
13 Updated ungolfed version
source | link
12 removed with i block
source | link
11 Capitalization
source | link
10 dim to set
source | link
9 google.nl
source | link
8 capitalization
source | link
7 assumed clean module
source | link