+ Reply to Thread
Results 1 to 2 of 2

Invalid call only when results are zero in Google search Excel.

  1. #1
    Registered User
    Join Date
    10-05-2011
    Location
    Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    3

    Invalid call only when results are zero in Google search Excel.

    Good evening,

    The code below works fine (Google search results in Excel) but only when results are zero I get an invalid call.

    How can I bypass this?

    Thanks in advance.

    Juul


    With Sheets("Sheet1")
    RowCount = 1
    Do While .Range("A" & RowCount) <> ""
    searchWords = .Range("A" & RowCount).Value


    ' Get keywords and validate by adding + for spaces between
    searchWords = Replace$(searchWords, " ", "+")

    ' Obtain the source code for the Google-searchterm webpage
    search_url = "http://www.google.com/search?hl=en&q=" & searchWords & "&meta="""
    Set search_http = CreateObject("MSXML2.XMLHTTP")
    search_http.Open "GET", search_url, False
    search_http.send
    results_var = search_http.responsetext
    Set search_http = Nothing

    ' Find the number of results and post to sheet
    pos_1 = InStr(1, results_var, "resultStats>", vbTextCompare)
    pos_2 = InStr(3 + pos_1, results_var, ">", vbTextCompare)
    pos_3 = InStr(pos_2, results_var, "<nobr>", vbTextCompare)
    NumberofResults = Mid(results_var, 1 + pos_2, (-1 + pos_3 - pos_2))
    Range("B" & RowCount) = NumberofResults
    RowCount = RowCount + 1

    ' Waits 5 seconds
    Application.Wait Time + TimeSerial(0, 0, 5)
    ' Continues here after pause

    Loop
    End With

    End Sub

  2. #2
    Registered User
    Join Date
    06-07-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Invalid call only when results are zero in Google search Excel.

    Did you ever find a resolution to this?

    when I run it I get this Error:

    Run-time error '-2147024891 (80070005)':
    Access is denied


    When I debug, it highlights:
    search_http.Send

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1